User Guide

956 MenuBar component (Flash Professional only)
Returns
A reference to the new Menu object.
Description
Method; Usage 1 adds a single menu and menu activator at the end of the menu bar and uses
the specified label. Usage 2 adds a single menu and menu activator that are defined in the
specified XML
menuDataProvider parameter.
Example
Usage 1: The following example adds a File menu and then uses Menu.addMenuItem() to add
the menu items New and Open.
Drag an instance of the MenuBar component onto the Stage, and enter the instance name
my_mb in the Property inspector. Add the following code to Frame 1 of the timeline:
/**
Requires:
- MenuBar component on Stage (instance name: my_mb)
*/
var my_mb:mx.controls.MenuBar;
var my_menu:mx.controls.Menu = my_mb.addMenu("File");
my_menu.addMenuItem({label:"New", instanceName:"newInstance"});
my_menu.addMenuItem({label:"Open", instanceName:"openInstance"});
Usage 2: The following example adds a Font menu with the menu items Bold and Italic,
which are defined in the XML data provider
myDP_xml.
Drag an instance of the MenuBar component onto the Stage, and enter the instance name
my_mb in the Property inspector. Add the following code to Frame 1 of the timeline:
/**
Requires:
- MenuBar component on Stage (instance name: my_mb)
*/
var my_mb:mx.controls.MenuBar;
var myDP_xml:XML = new XML();
myDP_xml.addMenuItem({type:"check", label:"Bold", instanceName:"check1"});
myDP_xml.addMenuItem({type:"check", label:"Italic",
instanceName:"check2"});
var my_menu:mx.controls.Menu = my_mb.addMenu("Font", myDP_xml);