<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initCollrction();">
 <mx:Panel x="73" y="10" width="503" height="293" layout="absolute">               <!--@label表示节点中的label值-->
  <mx:MenuBar itemClick="menuevent(event)" x="0" y="0" width="483" height="36" dataProvider="{xmllistcollection}" labelField="@label"></mx:MenuBar>
  <mx:TextArea x="0" y="35" width="483" height="218" id="txtall"/>
 </mx:Panel>
 <mx:Script>
  <![CDATA[
   import mx.controls.MenuBar;
   import mx.controls.Alert;
   import mx.events.MenuEvent;
   import mx.collections.*;
   [Bindable]
   public var xmllistcollection:XMLListCollection;
   private var xmllist:XMLList=
   <>
    <menuitem label="文件" data="file">
     <menuitem label="打开" data="new"/>
     <menuitem label="保存" data="save"/>
     <menuitem type="separator"/>
     <menuitem label="关闭" data="close"/>
    </menuitem>
    <menuitem label="编辑" data="edit">
     <menuitem label="撤销" data="undo" type="check"/>
     <menuitem label="重做" data="redo" type="check"/>
     <menuitem type="separator"/>
     <menuitem label="操作" data="command">
      <menuitem label="剪贴" type="radio" data="cut" groupName="one"/>
      <menuitem label="复制" type="radio" data="copy" groupName="one"/>
     </menuitem>
    </menuitem>
   </>;
   
   private function initCollrction():void{
    xmllistcollection=new XMLListCollection(xmllist);
   }
   
   private function menuevent(event:MenuEvent):void{
    txtall.text+=event.label+"-"+event.index+"\n";
   }
   
  ]]>
 </mx:Script>
</mx:Application>

 flex组件使用【MenuBar】_MenuBar