User Guide

538 Chapter 6: Components Dictionary
Menu component (Flash Professional only)
The Menu component lets a user select an item from a pop-up menu, much like the File or Edit
menu of most software applications.
A Menu component usually opens in an application when a user rolls over or clicks a button-like
menu activator. You can also script a Menu component to open when a user presses a certain key.
Menu components are always created dynamically at runtime. You must add the component to
the document from the Components panel, and delete it to add it to the library. Then, use the
following code to create a menu with ActionScript:
var myMenu = mx.controls.Menu.createMenu(parent, menuDataProvider);
Use the following code to open a menu in an application:
myMenu.show(x, y);
A menuShow event is broadcast to all of the Menu instance’s listeners immediately before the menu
is rendered, so you can update the state of the menu items. Similarly, immediately after a Menu
instance is hidden, a
menuHide event is broadcast.
The items in a menu are described by XML. For more information, see “Understanding the
Menu component: view and data” on page 540.
You cannot make the Menu component accessible to screen readers.
Interacting with the Menu component (Flash Professional only)
You can use the mouse and keyboard to interact with a Menu component.
After a Menu component is opened, it remains visible until it is closed by a script or until the user
clicks the mouse outside the menu or inside an enabled item.
Clicking selects a menu item, except with the following types of menu items:
Disabled items or separators Rollovers and clicks have no effect (the menu remains visible).
Anchors for a submenu Rollovers activate the submenu; clicks have no effect; rolling onto any
item other than those of the submenu closes the submenu.
When an item is selected, a
Menu.change event is sent to all of the menus listeners, the menu is
hidden, and the following actions occur, depending on item type:
check The items selected attribute is toggled.
radio The item becomes the current selection of its radio group.
Moving the mouse triggers
Menu.rollOut and Menu.rollOver events.
Pressing the mouse outside the menu closes the menu and triggers a
Menu.menuHide event.
Releasing the mouse in an enabled item affects item types in the following ways:
check The items selected attribute is toggled.
CHAPTER 6
Components Dictionary