User Guide
172 ComboBox component
ComboBox.addItemAt()
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004.
Usage
comboBoxInstance.addItemAt(index, label[, data])
comboBoxInstance.addItemAt(index, {label:label[, data:data]})
comboBoxInstance.addItemAt(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; it can be of any data type. This parameter is optional.
obj An object with label and data properties.
Returns
The index at which the item was added.
Description
Method; adds a new item to the end of the list at the index specified by the index parameter.
Indices greater than
ComboBox.length are ignored.
Example
Start with a ComboBox component instance named my_cb, and a Button component
instance named
my_btn. Add the following ActionScript to the Actions panel for the first
frame of the main timeline. When you test the SWF file, click the combo box to see two items
in it. Then click the button, and the next time you click the combo box, you’ll see that it
added another item labeled “first value”:
my_cb.addItem({data:2, label:"second value"});
my_cb.addItem({data:3, label:"third value"});
var btnListener:Object = new Object();
btnListener.click = function() {
my_cb.addItemAt(0, {data:1, label:"first value"});
};
my_btn.addEventListener("click", btnListener);