User Guide

Menu component (Flash Professional only) 543
Radio button menu items
Menu items whose
type attribute is set to radio can be grouped together so that only one of the
items can be selected at a time. You create a radio group by giving the menu items the same value
for their
groupName attribute, as in the following example:
<menu>
<menuitem label="Center" type="radio" groupName="alignment_group"
instanceName="center_item"/>
<menuitem type="separator" />
<menuitem label="Top" type="radio" groupName="alignment_group" />
<menuitem label="Bottom" type="radio" groupName="alignment_group" />
<menuitem label="Right" type="radio" groupName="alignment_group" />
<menuitem label="Left" type="radio" groupName="alignment_group" />
</menu>
When the user selects one of the items, the current selection automatically changes, and a change
event is broadcast to all listeners on the root menu. The currently selected item in a radio group is
available in ActionScript through the
selection property, as follows:
var selectedMenuItem = myMenu.alignment_group.selection;
myMenu.alignment_group = myMenu.center_item;
Each groupName value must be unique within the scope of the root menu instance.
Note: The selected attribute should be modified only with the setMenuItemSelected() method. You
can directly examine the
selected attribute, but it returns a string value of true or false.
Exposing menu items to ActionScript
You can assign each menu item a unique identifier in the
instanceName attribute, which makes
the menu item accessible directly from the root menu. For example, the following XML code
provides
instanceName attributes for each menu item:
<menu>
<menuitem label="Item 1" instanceName="item_1" />
<menuitem label="Item 2" instanceName="item_2" >
<menuitem label="SubItem A" instanceName="sub_item_A" />
<menuitem label="SubItem B" instanceName="sub_item_B" />
</menuitem>
</menu>
You can use ActionScript to access the corresponding instances and their attributes directly from
the menu component, as follows:
var aMenuItem = myMenu.item_1;
myMenu.setMenuItemEnabled(item_2, true);
var aLabel = myMenu.sub_item_A.label;
Note: Each instanceName attribute must be unique within the scope of the root menu component
instance (including all of the submenus of root).