User Guide

540 Chapter 6: Components Dictionary
Understanding the Menu component: view and data
Conceptually, the Menu component consists of a data model and a view that displays the data.
The Menu class provides the view and contains the visual configuration methods. The
MenuDataProvider class adds methods to the global XML prototype object (much like the
DataProvider API does to the Array object); these methods let you externally construct data
providers and add them to multiple menu instances. The data provider broadcasts any changes to
all of its client views. (See “MenuDataProvider class” on page 568.)
A Menu instance is a hierarchical collection of XML elements that correspond to individual menu
items. The attributes define the behavior and appearance of the corresponding menu item on the
screen. The collection is easily translated to and from XML, which is used to describe menus (the
menu tag) and items (the menuitem tag). The built-in ActionScript XML class is the basis for the
model underlying the Menu component.
A simple menu with two items can be described in XML with two menu item subelements:
<menu>
<menuitem label="Up" />
<menuitem label="Down" />
</menu>
Note: The tag names of the XML nodes (
menu and menuitem) are not important; the attributes and
their nesting relationships are used in the menu.
About hierarchical menus
To create hierarchical menus, embed XML elements within a parent XML element, as follows:
<menu>
<menuitem label="MenuItem A" >
<menuitem label="SubMenuItem 1-A" />
<menuitem label="SubMenuItem 2-A" />
</menuitem>
<menuitem label="MenuItem B" >
<menuitem label="SubMenuItem 1-B" />
<menuitem label="SubMenuItem 2-B" />
</menuitem>
</menu>
This converts the parent menu item into a pop-up menu anchor, so it does not generate events
when selected.