ActionScript 2.0 Components Language Reference |
|
|
|
| Menu component > Menu.createMenu() | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
Menu.createMenu([parent[,mdp]])
parent A MovieClip instance. The movie clip is the parent component that contains the new Menu instance. This parameter is optional.
mdp The MenuDataProvider instance that describes this Menu instance. This parameter is optional.
A reference to the new menu instance.
Method (static); instantiates a Menu instance, and optionally attaches it to the specified parent, with the specified MenuDataProvider as the data source for the menu items.
If the parent parameter is omitted or null, the Menu is attached to the _root timeline.
If the mdp parameter is omitted or null, the menu does not have any items; you must call addMenu() or setDataProvider() to populate the menu.
The following example creates a menu with a submenu for the New menu item. It creates the menu by creating an XML object, my_xml, and adding menu items to it with calls to addMenuItem(). It then creates the menu with a call to createMenu(), passing the XML object as the data provider.
You first drag a Menu component to the library and then add the following code to Frame 1:
/**
Requires:
- Menu component in library
*/
import mx.controls.Menu;
var my_xml:XML = new XML();
var newItem_obj:Object = my_xml.addMenuItem({label:"New"});
// Create other submenu items for main menu.
my_xml.addMenuItem({label:"Open", instanceName:"miOpen"});
my_xml.addMenuItem({label:"Save", instanceName:"miSave"});
my_xml.addMenuItem({type:"separator"});
my_xml.addMenuItem({label:"Quit", instanceName:"miQuit"});
// Create submenu items for "New" submenu.
newItem_obj.addMenuItem({label:"File..."});
newItem_obj.addMenuItem({label:"Project..."});
newItem_obj.addMenuItem({label:"Resource..."});
// Create menu.
var my_menu:Menu = Menu.createMenu(myParent_mc, my_xml);
my_menu.show(100, 20);
|
|
|
|