ComboBox.replaceItemAt()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

comboBoxInstance.replaceItemAt(index, label[, data])
comboBoxInstance.replaceItemAt(index, {label:label[, data:data]})
comboBoxInstance.replaceItemAt(index, obj);

Parameters

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.

Returns

Nothing.

Description

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.

Example

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);

See also

ComboBox.removeAll(), ComboBox.removeItemAt()