ActionScript 2.0 Components Language Reference |
|
|
|
| List component > List.addItemAt() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
listInstance.addItemAt(index,label[,data])listInstance.addItemAt(index,itemObject)
index A number greater than or equal to 0 that indicates the position of the item.
label A string that indicates the label for the new item.
data The data for the item. This parameter is optional and can be of any data type.
itemObject An item object that usually has label and data properties.
The index at which the item was added.
Method; adds a new item to the position specified by the index parameter.
In the first usage example, an item object is always created with the specified label property, and, if specified, the data property.
The second usage example adds the specified item object.
Calling this method modifies the data provider of the List component. If the data provider is shared with other components, those components are updated as well.
The following example adds an item to the first index position, which is the second item in the list. To try this code, drag a List component to the Stage and give it the instance name my_list. Add the following code to Frame 1 in the timeline:
var my_list:mx.controls.List;
my_list.addItem("this is an Item");
my_list.addItem({label:"Gordon", age:"very old", data:123});
my_list.addItemAt(1, {label:"Red", data:0xFF0000});
|
|
|
|