Use the itemClick event instead of the click event. vis...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.events.MenuEvent;
private function menuHandler(event:MenuEvent):void
{
trace(event.it...@data);
}
]]>
</mx:Script>
<mx:MenuBar x="0" y="80" width="100%" id="mainMB"
itemClick="menuHandler(event)" labelField="@label">
<mx:XMLList>
<menuitem label="Practice Tests">
<menuitem label="Load Test" data="load"/>
<menuitem label="End Test" data="cancel"/>
</menuitem>
</mx:XMLList>
</mx:MenuBar>
</mx:Application>
--- In [email protected], "Wally Kolcz" <wko...@...> wrote:
>
> I am working on a couple AIR apps that would best be served with a
menu bar. Problem is, as where I do understand how to make menu items, I
cannot figure out how to trigger a function or switch a viewstack when
a menu item is clicked.
>
> Lets say I have this:
> <mx:MenuBar x="0" y="80" width="100%" id="mainMB"
click="menuHandler(event)" labelField="@label">
> <mx:XMLList>
> <menuitem label="Practice Tests">
> <menuitem label="Load Test" data="load"/>
> <menuitem label="End Test" data="cancel"/>
> </menuitem>
> </mx:XMLList>
> </mx:MenuBar>
>
> I want to trigger a function when either the load or cancel is
selected. How?
>