ComboBox component

A combo box allows a user to make a single selection from a pop-up list. A combo box can be static or editable. An editable combo box allows a user to enter text directly into a text field at the top of the list, as well as selecting an item from a pop-up list. If the pop-up list hits the bottom of the document, it opens up instead of down. The combo box is composed of three subcomponents: a Button component, a TextInput component, and a List component.

NOTE

A ComboBox component is supported for both ActionScript 2.0 and ActionScript 3.0. This document discusses the version 2 component. If you are using the version 3 component, see Using the ComboBox in Using ActionScript 3.0 Components.

When a selection is made in the list, the label of the selection is copied to the text field at the top of the combo box. It doesn't matter if the selection is made with the mouse or the keyboard.

A ComboBox component receives focus if you click the text box or the button. When a ComboBox component has focus and is editable, all keystrokes go to the text box and are handled according to the rules of the TextInput component (see TextInput component), with the exception of the following keys:

Key

Description

Control+Down Arrow

Opens the drop-down list and gives it focus.

Shift+Tab

Moves focus to the previous object.

Tab

Moves focus to the next object.

When a ComboBox component has focus and is static, alphanumeric keystrokes move the selection up and down the drop-down list to the next item with the same first character. You can also use the following keys to control a static combo box:

Key

Description

Control+Down Arrow

Opens the drop-down list and gives it focus.

Control+Up Arrow

Closes the drop-down list, if open in the stand-alone and browser versions of Flash Player.

Down Arrow

Moves the selection down one item.

End

Selection moves to the bottom of the list.

Escape

Closes the drop-down list and returns focus to the combo box in test mode.

Enter

Closes the drop-down list and returns focus to the combo box.

Home

Moves the selection to the top of the list.

Page Down

Moves the selection down one page.

Page Up

Moves the selection up one page.

Shift+Tab

Moves focus to the previous object.

Tab

Moves focus to the next object.

When the drop-down list of a combo box has focus, alphanumeric keystrokes move the selection up and down the drop-down list to the next item with the same first character. You can also use the following keys to control a drop-down list:

Key

Description

Control+Up Arrow

If the drop-down list is open, focus returns to the text box and the drop-down list closes in the stand-alone and browser versions of Flash Player.

Down Arrow

Moves the selection down one item.

End

Moves the insertion point to the end of the text box.

Enter

If the drop-down list is open, focus returns to the text box and the drop-down list closes.

Escape

If the drop-down list is open, focus returns to the text box and the drop-down list closes in test mode.

Home

Moves the insertion point to the beginning of the text box.

Page Down

Moves the selection down one page.

Page Up

Moves the selection up one page.

Tab

Moves focus to the next object.

Shift+End

Selects the text from the insertion point to the End position.

Shift+Home

Selects the text from the insertion point to the Home position.

Shift+Tab

Moves focus to the previous object.

Up Arrow

Moves the selection up one item.

NOTE

The page size used by the Page Up and Page Down keys is one less than the number of items that fit in the display. For example, paging down through a ten-line drop-down list will show items 0-9, 9-18, 18-27, and so on, with one item overlapping per page.

For more information about controlling focus, see FocusManager class or Creating custom focus navigation in Using ActionScript 2.0 Components.

A live preview of each ComboBox component instance on the Stage reflects changes made to parameters in the Property inspector or Component inspector during authoring. However, the drop-down list does not open in the live preview, and the first item is displayed as the selected item.

When you add the ComboBox component to an application, you can use the Accessibility panel to make it accessible to screen readers. First, you must add the following line of code to enable accessibility:

mx.accessibility.ComboBoxAccImpl.enableAccessibility();

You enable accessibility for a component only once, regardless of how many instances the component has. For more information, see "Creating accessible content" in Using Flash.

Related topics