ActionScript 2.0 Components Language Reference |
|
|
|
| List component > List.removeAll() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
listInstance.removeAll()
Nothing.
Method; removes all items in the list.
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 code clears all items 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) {
my_list.removeAll();
evt_obj.target.enabled = false;
}
remove_button.addEventListener("click", buttonListener);
|
|
|
|