PackageTop Level
Classpublic class Menu

This class can be used to display a context menus via the popupMenu() function of some objects. Menus are built by appending menu items to them.


Example
The following code creates a new menu and append a menu item to it:
  
 -- Create a new menu  
 menu = Menu:new("My menu")  
  
 -- Create a new menu item  
 menuItem = MenuItem:new("my menu item")  
  
 -- (Optional) Give the item an id that can be used later on to track a menu item  
 menuItem:setId("some id")  
  
 -- (Optional) The "tag" property can be used to attach additional data to the menu item  
 menuItem:setTag("some extra info")  
  
 -- (Optional) Name of the function that is going to be called when/if the menu item is selected  
 menuItem:setOnSelected("menuItem_selected")  
  
 -- Add the menu item to the menu  
 subMenu:append(menuItem)  
  
 function menuItem_selected(event)  
     trace("Menu item with id ", event.menuItem:getId(), " and tag ", event.menuItem:getTag(), " was clicked")  
 end  
 



Public Methods
 MethodDefined by
  
Menu(menuLabel:String)
Constructor.
Menu
  
append(menuItem:MenuItem):void
Appends a menu item to the menu.
Menu
  
Appends a separator item to the menu.
Menu
  
appendSubMenu(menu:Menu):void
Appends a submenu to the menu.
Menu
Constructor detail
Menu()constructor
public function Menu(menuLabel:String)

Constructor.

Parameters
menuLabel:String — Menu label.
Method detail
append()method
public function append(menuItem:MenuItem):void

Appends a menu item to the menu.

Parameters
menuItem:MenuItem — Menu item to append to the menu.
appendSeparator()method 
public function appendSeparator():void

Appends a separator item to the menu.

appendSubMenu()method 
public function appendSubMenu(menu:Menu):void

Appends a submenu to the menu.

Parameters
menu:Menu — Submenu to append to the menu.

Example
The following code creates a new menu and append a submenu to it:
  
 -- Create the submenu  
 submenu = Menu:new("My menu")  
  
 -- Append an item to it  
 menuItem = MenuItem:new("submenu item")  
 submenu:append(menuItem)  
  
 -- Append the submenu to an existing menu  
 someMenu:appendSubMenu(submenu)