ActionScript 2.0 Components Language Reference |
|
|
|
| ComboBox component > ComboBox.replaceItemAt() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
comboBoxInstance.replaceItemAt(index,label[,data])comboBoxInstance.replaceItemAt(index, {label:label[, data:data]})comboBoxInstance.replaceItemAt(index,obj);
index A number 0 or greater that indicates the position at which to insert the item (the index of the new item).
label A string that indicates the label for the new item.
data The data for the item. This parameter is optional.
obj An object with label and data properties.
Nothing.
Method; replaces the content of the item at the specified index. This is a method of the List component that is available from the ComboBox component.
With a ComboBox component instance my_cb, and a TextInput component instance label_ti on the Stage, the following ActionScript code adds the user input to the combo box when the user presses the Enter key:
// Add Items to List.
my_cb.addItem({data:1, label:"First Item"});
my_cb.addItem({data:2, label:"Second Item"});
// Create listener for user pressing Enter key on the Text Input field.
var tiListener:Object = new Object();
tiListener.enter = function(evt_obj:Object) {
my_cb.replaceItemAt(my_cb.selectedIndex, {label:evt_obj.target.text});
// Needed to refresh recently modified ComboBox entry
my_cb.selectedIndex = my_cb.selectedIndex;
};
label_ti.addEventListener("enter", tiListener);
ComboBox.removeAll(), ComboBox.removeItemAt()
|
|
|
|