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. Although a radio button menu item behaves similarly to a RadioButton component, a radio button menu item appears visually without the border surrounding the button. So an unselected radio button menu item looks like a Normal menu item until selected.

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.