User Guide
List.replaceItemAt() 795
Description
Method; removes the item at the specified index position. The list indices after the specified
index collapse by one.
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.
Example
The following code clears the selected item in a List component when a button is clicked. 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 remove_button. Add the
following code to Frame 1 in the timeline:
var my_list:mx.controls.List;
var remove_button:mx.controls.Button;
remove_button.label = "Remove";
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.removeItemAt(my_list.selectedIndex);
}
}
remove_button.addEventListener("click", buttonListener);
List.replaceItemAt()
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004.
Usage
listInstance.replaceItemAt(index, label[, data])
listInstance.replaceItemAt(index, itemObject)