List.selectedIndices

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

listInstance.selectedIndices

Description

Property; an array of indices of the selected items. Assigning this property replaces the current selection. Setting selectedIndices to a zero-length array (or undefined) clears the current selection. The value is undefined if nothing is selected.

The selectedIndices property reflects the order in which the items were selected. If you click the second item, then the third item, and then the first item, selectedIndices returns [1,2,0].

Example

The following example retrieves the selected indices:

var selIndices:Array = my_list.selectedIndices;

The following example selects four items:

var my_array = new Array (1, 4, 5, 7);
my_list.selectedIndices = my_array;

The following example selects two list items by default and displays their label property in the Output panel:

my_list.multipleSelection = true;

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

my_list.selectedIndices = [0, 2]; 

var numSelected:Number = my_list.selectedIndices.length;
for (var i:Number = 0; i < numSelected; i++) {
    trace("selectedIndices[" + i + "] = "+ my_list.getItemAt(my_list.selectedIndices[i]).label);
}

See also

List.selectedIndex, List.selectedItem, List.selectedItems