F > FListBox.getSelectedItem |  |

FListBox.getSelectedItem

FListBox, FListBox.getSelectedItem, getSelectedItem

Availability

Flash Player 6.

Usage

    myListBox.getSelectedItem()

Parameters

None.

Returns

An object or `undefined`.

Description

Method; returns the currently selected item as an object with the properties `label` and `data`. If more than one item is selected, the method returns the most recently selected item in the list; if no items are selected, the method returns `undefined`. To retrieve information about all selected items in a multiple-selection list box, use `FListBox.getSelectedItems`.

Example

The following code returns the label of the item currently selected in `listBox1`.

    trace(listBox1.getSelectedItem().label);

The following code returns the data or value associated with item currently selected in `listBox2`.

    trace(listBox2.getSelectedItem().data);

The following code returns an object containing the label and the data value associated with the item currently selected in `listBox3`.

    trace(listBox3.getSelectedItem());

See also

`FListBox.getItemAt`