ComboBox.selectedItem

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

comboBoxInstance.selectedItem

Description

Property; the value of the selected item in the drop-down list.

If the combo box is editable, selectedItem returns undefined if the user enters any text in the text box. The property only has a value if you select an item from the drop-down list or set the value using ActionScript. If the combo box is static, the value of selectedItem is always valid; it returns undefined if there are no items in the list.

Example

With a ComboBox component instance my_cb, the following example shows the values for the selectedItem data and label properties:

// Add Items to List.
my_cb.addItem({data:1, label:"First Item"});
my_cb.addItem({data:2, label:"Second Item"});
my_cb.addItem({data:3, label:"Third Item"});
my_cb.addItem({data:4, label:"Fourth Item"});

var cbListener:Object = new Object();
cbListener.change = function(evt_obj:Object) {
 var item_obj:Object = my_cb.selectedItem;
 var i:String;
 for (i in item_obj) {
  trace(i + ":\t" + item_obj[i]);
 }
 trace("");
};
my_cb.addEventListener("change", cbListener);

See also

ComboBox.dataProvider, ComboBox.selectedIndex