flex中menuBar

<?xml version="1.0" encoding="utf-8"?>
<!--http://www.javaeye.com/topic/210348-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()"> 
      
    <mx:Style source="style.css"/>              
    <mx:Script> 
        <![CDATA[ 
            import mx.controls.Alert;        
            import mx.events.MenuEvent; 
             
            private var mXML:XML = 
                <menu label = "系统菜单"> 
                    <item label="文件"> 
                        <node label="新建画板" data="new"/> 
                        <node label="清除画板" data="clear" enabled="false"/> 
                        <node type="separator" /> 
                        <node label="退出系统" data="logout"/> 
                    </item> 
                    <item label="帮助"> 
                        <node label="帮助" data="help"/> 
                        <node label="关于作者" data="about"/> 
                     </item> 
                </menu>; 
             
            internal function initApp():void{ 
                //为MenuBar添加数据源 
                myMenu.dataProvider = mXML; 
                //监听Menu的点击实践 
                myMenu.addEventListener(MenuEvent.ITEM_CLICK,menuClickHandler); 
            } 
             
            internal function menuClickHandler(evt:MenuEvent):void{ 
                Alert.show("选择菜单:"+evt.item.@data,"提示信息"); 
            } 
        ]]> 
    </mx:Script> 
    <mx:VBox width="100%" height="100%"> 
        <mx:Canvas styleName="windowBar" width="100%"> 
            <mx:MenuBar labelField="@label"  height="30" id="myMenu" width="100%"></mx:MenuBar>   
        </mx:Canvas> 
        <mx:Canvas width="100%" height="100%" id="paper"> 
              
        </mx:Canvas>            
    </mx:VBox> 
      
</mx:Application> 
 
    A+
发布日期:2009年05月19日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: