ComboBox class

Inheritance UIObject > UIComponent > ComboBase > ComboBox

ActionScript Class Namespace mx.controls.ComboBox

The ComboBox component combines three separate subcomponents: Button, TextInput, and List. Most of the APIs of each subcomponent are available directly from ComboBox component and are listed in the Method, Property, and Event tables for the ComboBox class.

The drop-down list in a combo box is provided either as an Array or as a DataProvider object. If you use a DataProvider object, the list changes at runtime. The source of the ComboBox data can be changed dynamically by switching to a new Array or DataProvider object.

Items in a combo box list are indexed by position, starting with the number 0. An item can be one of the following:

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 component 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.

Each component class has a version property which is a class property. Class properties are only available on the class itself. The version property returns a string that indicates the version of the component. To access the version property, use the following code:

trace(mx.controls.ComboBox.version);

Note: The following code returns undefined: trace(myComboBoxInstance.version);.

Method summary for the ComboBox class

Property

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.

ComboBox.removeItemAt()

Removes an item from the list at the specified location.

ComboBox.replaceItemAt()

Replaces an item in the list with another specified item.

Inherits all methods from UIObject class and UIComponent class.

Property summary for the ComboBox class

Property

Description

ComboBox.dataProvider

The data model for the items in the list.

ComboBox.dropdown

Returns a reference to the List component contained by the combo box.

ComboBox.dropdownWidth

The width of the drop-down list, in pixels.

ComboBox.editable

Indicates whether or not a combo box is editable.

ComboBox.labelField

Indicates which data field to use as the label for the drop-down list.

ComboBox.labelFunction

Specifies a function to compute the label field for the drop-down list.

ComboBox.length

Read-only. The length of the drop-down list.

ComboBox.rowCount

The maximum number of list items to display at one time.

ComboBox.selectedIndex

The index of the selected item in the drop-down list.

ComboBox.selectedItem

The value of the selected item in the drop-down list.

ComboBox.text

The string of the text in the text box.

ComboBox.textField

A reference to the TextInput component in the combo box.

ComboBox.value

The value of the text box (editable) or drop-down list (static).

Inherits all properties from UIObject class and UIComponent class.

Event summary for the ComboBox class

Event

Description

ComboBox.change

Broadcast when the value of the combo box changes as a result of user interaction.

ComboBox.close

Broadcast when the drop-down list begins to close.

ComboBox.enter

Broadcast when the Enter key is pressed.

ComboBox.itemRollOut

Broadcast when the pointer rolls off a drop-down list item.

ComboBox.itemRollOver

Broadcast when a drop-down list item is rolled over.

ComboBox.open

Broadcast when the drop-down list begins to open.

ComboBox.scroll

Broadcast when the drop-down list is scrolled.

Inherits all events from UIObject class and UIComponent class.