Provides a selection from a collection of items.

Available since

1.0.0

.

Variables

@:flash.propertyselectedItem:T

The currently selected item. Returns null if no item is selected.

When the value of the selectedItem property changes, the component will dispatch an event of type Event.CHANGE.

The following example changes the selected item:

list.selectedItem = newItem;

Note: If the new item is not in the item collection, the selected item will be set to null instead.

The following example clears the currently selected item:

control.selectedItem = null;

The following example listens for when the selection of a ListView component changes, and it requests the new selected index:

var listView = new ListView();
function changeHandler(event:Event):Void
{
	var listView = cast(event.currentTarget, ListView);
	var text = listView.itemToText(listView.selectedItem);
	trace("selection change: " + text);
}
listView.addEventListener(Event.CHANGE, changeHandler);
Available since

1.0.0

.

See also: