Creating a menu from scratch
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#FFFFFF">
<mx:XMLListCollection id="myMenuData">
<mx:XMLList>
<menuitem label="File">
<submenu label="New" />
<submenu label="Open">
<submenu label="Doc" />
<submenu label="Pdf" />
</submenu>
</menuitem>
</mx:XMLList>
</mx:XMLListCollection>
<mx:Script>
import mx.controls.Menu;
public var myMenu:Menu;
private function InitializeMenu():void
{
myMenu = Menu.createMenu(null, myMenuData,true);
myMenu.labelField="@label";
}
</mx:Script>
<mx:Button id="myButton" creationComplete="InitializeMenu()" label="Display Menu" click="myMenu.show()" />
</mx:Application>
Related examples in the same category