List.selectedItems

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

listInstance.selectedItems

Description

Property (read-only); an array of the selected item objects. In a multiple-selection list, selectedItems lets you access the set of items selected as item objects.

Example

The following example retrieves an array of selected item objects:

var myObjArray:Array = my_list.selectedItems;

The following example displays two List instances on the Stage. When a user selects an item from the first list, the selected item is copied to the second list. To try this code, you must add a copy of the List component to the library of the current document. Add the following code to Frame 1 in the timeline:

this.createClassObject(mx.controls.List, "my_list", 10, {multipleSelection:true});
my_list.setSize(200, 100);

this.createClassObject(mx.controls.List, "selectedItems_list", 20, {selectable:false});
selectedItems_list.setSize(200, 100);
selectedItems_list.move(0, 110);

my_list.addItem({data:"flash", label:"Flash"});
my_list.addItem({data:"dreamweaver", label:"Dreamweaver"});
my_list.addItem({data:"coldfusion", label:"ColdFusion"});

var listListener:Object = new Object();
listListener.change = function(evt_obj:Object) {
    trace("You have selected " + my_list.selectedItems.length + " items.");
    selectedItems_list.dataProvider = my_list.selectedItems;
}
my_list.addEventListener("change", listListener);

See also

List.selectedIndex, List.selectedItem, List.selectedIndices