ActionScript 2.0 Components Language Reference |
|
|
|
| List component > List.replaceItemAt() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
listInstance.replaceItemAt(index,label[,data])listInstance.replaceItemAt(index,itemObject)
index A number greater than 0 and less than List.length 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 and can be of any type.
itemObject An object to use as the item, usually containing label and data properties.
Nothing.
Method; replaces the content of the item at the specified index.
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 replaces the item at the currently selected position. To try this code, drag a List component to the Stage and give it the instance name my_list. Next, drag a Button component to the Stage and give it the instance name replace_button. Add the following code to Frame 1 in the timeline:
var my_list:mx.controls.List;
var replace_button:mx.controls.Button;
replace_button.label = "Replace";
my_list.addItem({data:"flash", label:"Flash"});
my_list.addItem({data:"dreamweaver", label:"Dreamweaver"});
my_list.addItem({data:"coldfusion", label:"ColdFusion"});
var buttonListener:Object = new Object();
buttonListener.click = function(evt_obj:Object) {
if (my_list.selectedIndex != undefined) {
my_list.replaceItemAt(my_list.selectedIndex, {data:"flex", label:"Flex"});
}
}
replace_button.addEventListener("click", buttonListener);
|
|
|
|