来源:http://www.cuplayer.com/player/PlayerCode/Flex/2013/0118661.html
<fx:Script>
<![CDATA[ import mx.controls.Alert; import mx.events.MenuEvent; protected function menubar1_itemClickHandler(event:MenuEvent):void { Alert.show(event.item.@label); } ]]> </fx:Script> <mx:MenuBar x="118" y="124" labelField="@label" itemClick="menubar1_itemClickHandler(event)"> <mx:dataProvider> <mx:XMLListCollection> <fx:XMLList xmlns=""> <menu label="aa"> <item label="aa1" /> <item label="aa2" /> </menu> <menu label="bb"> <item label="bb1" /> <item label="bb2" /> </menu> </fx:XMLList> </mx:XMLListCollection> </mx:dataProvider> </mx:MenuBar>经测试可用。。。。转载请标明原文出处。。
<mx:MenuBar y="90" labelField="@label" iconField="@icon" height="30" width="100%" itemClick="munuItemClickHandler(event)">
<mx:dataProvider> <mx:XMLListCollection> <fx:XMLList id="menuBar"> <menuitem label="文件"> <menuitem label="打开"/> <menuitem label="保存" enabled="false" icon="myIcon"/> <menuitem label="另存为..." type="check" toggled="true"/> <menuitem label="" type="separator"/> <menuitem label="输出"> <menuitem label="BMPL" type="radio" groupName="one"/> <menuitem label="图片" type="radio" groupName="one" toggled="true"/> </menuitem> <menuitem label="打印"/> <menuitem label="退出"/> </menuitem> <menuitem label="编辑"/> <menuitem label="查看"/> <menuitem label="工具"/> <menuitem label="帮助"/> </fx:XMLList> </mx:XMLListCollection> </mx:dataProvider> </mx:MenuBar>