User Guide

182 Chapter 6: Components Dictionary
ComboBox class
Inheritance MovieClip > UIObject class > UIComponent class > ComboBase > ComboBox
ActionScript Class Name mx.controls.ComboBox
The ComboBox component combines three separate subcomponents: Button, TextInput, and
List. Most of the methods, properties, and events of each subcomponent are available directly
from the ComboBox component and are listed in the summary tables for the ComboBox class.
The drop-down list in a combo box is provided either as an array or as a data provider. If you use
a data provider, the list changes at runtime. You can change the source of the ComboBox data
dynamically by switching to a new array or data provider.
Items in a combo box list are indexed by position, starting with the number 0. An item can be one
of the following:
A primitive data type.
An object that contains a label property and a data property
Note: An object may use the ComboBox.labelFunction or ComboBox.labelField property to
determine the
label property.
If the item is a primitive data type other than String, it is converted to a string. If an item is an
object, the
label property must be a string and the data property can be any ActionScript value.
ComboBox methods to which you supply items have two parameters,
label and data, that refer
to the properties above. Methods that return an item return it as an object.
A combo box defers the instantiation of its drop-down list until a user interacts with it. Therefore,
a combo box may appear to respond slowly on first use.
Use the following code to programmatically access the ComboBox components drop-down list
and override the delay:
var foo = myComboBox.dropdown;
Accessing the drop-down list may cause a pause in the application. This may occur when the user
first interacts with the combo box, or when the above code runs.
Method summary for the ComboBox class
The following table lists methods of the ComboBox class.
Method Description
ComboBox.addItem() Adds an item to the end of the list.
ComboBox.addItemAt() Adds an item to the end of the list at the specified index.
ComboBox.close() Closes the drop-down list.
ComboBox.getItemAt() Returns the item at the specified index.
ComboBox.open() Opens the drop-down list.
ComboBox.removeAll() Removes all items in the list.