Usage 2:
menuInstance.addMenuItem(childMenuItem)
Parameters
An object containing properties that initialize a menu item's attributes. See
initObject
"About menu item XML attributes" on page
887.
An XML node object.
childMenuItem
Returns
A reference to the added XML node.
Description
Method; Usage 1 adds a menu item at the end of the menu. The menu item is constructed
from the values supplied in the
parameter. Usage 2 adds a menu item that is a
initObject
prebuilt XML node (in the form of an XML object) at the end of the menu. Adding a
preexisting node removes the node from its previous location.
Example
The following example creates two menus, initially adding one menu item to each. The
example then adds two more menu items to the first menu, calling
to add the
addMenuItem()
first menu item by specifying its attributes. It then adds the second menu item by using the
prebuilt menu item node from the second menu.
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;
// Create the Menu objects.
var first_menu:Menu = Menu.createMenu();
first_menu.addMenuItem({label:"1st Item"});
var second_menu:Menu = Menu.createMenu();
second_menu.addMenuItem({label:"1st Item 2nd Menu"});
// First usage method
first_menu.addMenuItem({label:"Radio Item", instanceName:"radioItem1",
type:"radio", selected:false, enabled:true, groupName:"myRadioGroup"});
// Second usage method
first_menu.addMenuItem(second_menu.getMenuItemAt(0));
// Show menu.
first_menu.show();
906
Menu component (Flash Professional only)
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers