Menu event index
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="white"> <mx:XMLListCollection id="myMenuData"> <mx:XMLList> <menuitem label="File"> <submenu label="New"> <submenu label="Pdf" /> <submenu label="Doc" /> </submenu> <submenu label="Print" /> </menuitem> <menuitem label="View"> <submenu label="Pdf" /> <submenu label="Doc" /> </menuitem> </mx:XMLList> </mx:XMLListCollection> <mx:Script> import mx.events.MenuEvent; private function handleMenuClick(evt:MenuEvent):void { mx.controls.Alert.show(evt.item.@label); lastEvent.text = "Selection:" + evt.item.@label + ", Position: " + evt.index; } </mx:Script> <mx:MenuBar id="myMBar" itemClick="handleMenuClick(event)" dataProvider="{myMenuData}" labelField="@label" /> <mx:Text id="lastEvent" /> </mx:Application>