13.3. Adding a Menu Form Control

Problem

You want to add a form control that allows the user to select a value or values from a menu.

Solution

Use a ComboBox or List component.

Discussion

The ComboBox and List components provide you with a simple way to add menu form controls to your Flash application. Flash Professional includes a Menu component that requires some slightly more advanced ActionScript than this book discusses, but for the purposes of this discussion, the term “menu” is meant in a general sense. Combo boxes are often referred to in laymen’s terms as drop-down or pop-up menus. A combo box will display only one menu item at a time, though you can open and close the menu to display more items at once. A user can select only one item at a time from a combo box. A list, on the other hand, cannot be opened and closed, but instead displays multiple selections at the same time. If the list contains too many items to fit within the vertical space, the list will be made scrollable. Though lists allow a user to select only one item at a time by default, it is possible to enable them to accept multiple selections.

You can add either a combo box or a list component by dragging an instance from the Components panel onto the stage. After you’ve created the instance, you should be sure to give it an instance name using the Property inspector. The instance name provides the way in which you can later retrieve the selected value or values from the menu form control.

The next thing you should ...

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.