layout="absolute">
import mx.controls.Menu;
import mx.events.MenuEvent;
private var myMenu:Menu;
private function createAndShow():void {
ta1.text="";
myMenu = Menu.createMenu(null, myMenuData, false);
myMenu.labelField="@label";
myMenu.addEventListener(MenuEvent.ITEM_CLICK, menuShowInfo);
myMenu.show(225, 10);
}
private function menuShowInfo(event:MenuEvent):void {
ta1.text="event.type: " + event.type;
ta1.text+="\nevent.label: " + event.label;
ta1.text+="\nevent.index: " + event.index;
if (event.item) {
ta1.text+="\nItem label: " + event.item.@label
ta1.text+="\nItem selected: " + event.item.@toggled;
ta1.text+= "\nItem type: " + event.item.@type;
}
}
[Bindable]
public var menuData:Array = [
{label: "MenuItem A", children: [
{label: "SubMenuItem A-1", enabled: false},
{label: "SubMenuItem A-2", type: "normal"}]},
{label: "MenuItem B", type: "check", toggled: true},
{label: "MenuItem C", type: "check", toggled: false},
{type: "separator"},
{label: "MenuItem D", children: [
{label: "SubMenuItem D-1", type: "radio", groupName: "g1"},
{label: "SubMenuItem D-2", type: "radio", groupName: "g1",toggled: true},
{label: "SubMenuItem D-3", type: "radio", groupName: "g1"}]}
];