首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex menubar popUpMenuButton主要示例

2012-10-29 
flex menubar popUpMenuButton重要示例取得选自菜单的文本(label),序号(index),自定义值(@value)value为自

flex menubar popUpMenuButton重要示例
取得选自菜单的文本(label),序号(index),自定义值(@value)value为自定义
可以根据@value的值来为每个菜单写上方法,呵呵;


参考:http://livedocs.adobe.com/flex/3_cn/   http://www.iteye.com/topic/210348

代码给出:


<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:Script>   <![CDATA[    import mx.controls.Alert;    import mx.controls.Menu    import mx.events.MenuEvent;      private function initMenu():void{     Menu(myPum.popUp).selectedIndex=2;        }    private function menuClick(evt:MenuEvent):void{        Alert.show( "你选择了:" + evt.label + ' 选择序号:' + evt.index + ' 自定义值:' + evt.item.@value, "结果");    }   ]]></mx:Script><mx:Style>   Alert{    fontSize:"14";    fontFamily:"宋体";      }</mx:Style><mx:XML id="myDP">   <root>    <submenuitem label="sjekfjakjahgk1" value="1" />    <submenuitem label="sjekfjakjahgk2" value="2" />    <submenuitem label="sjekfjakjahgk3" value="3" />    <submenuitem label="sjekfjakjahgk4" value="4" />    <submenuitem type="separator"/>    <submenuitem label="sjekfjakjahgk5" value="5" />    <submenuitem label="sjekfjakjahgk6" value="6" />    <submenuitem label="sjekfjakjahgk7" value="7" />    <submenuitem label="sjekfjakjahgk8" value="8" />    <submenuitem label="sjekfjakjahgk9" value="9" />      </root></mx:XML><mx:PopUpMenuButton x="116" y="72" id="myPum" dataProvider="{myDP}"   showRoot="false" labelField="@label" itemClick="menuClick(event);"    creationComplete="initMenu()">  </mx:PopUpMenuButton></mx:Application>

MenuBar示例如下:

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"backgroundColor="0xCCCCCC" fontSize="12"paddingLeft="0" paddingRight="0" paddingTop="10"><mx:Script>   <![CDATA[      import mx.controls.*      import mx.events.*    private function menuClick(evt:MenuEvent):void{        Alert.show( "你选择了:" + evt.label + ' 选择序号:' + evt.index + ' 自定义值:' + evt.item.@data, "结果");           }   ]]></mx:Script>    <mx:MenuBar id="myMenuBar" labelField="@label" showRoot="false" itemClick="menuClick(event)">      <mx:XML>        <root>                 <menuitem label="展示层实现" >            <submenuitem label="HTML开发王" type="check" data="b1"/>            <submenuitem label="CSS开发王" type="check" data="b2"/>            <submenuitem label="JavaScript开发王" type="radio" groupname="js" data="b3"/>            <submenuitem label="Flash ActionScript 3.0开发王" type="radio" groupname="js" data="b4"/>            <submenuitem label="Flex开发王" type="check" toggled="true" data="b5"/>          </menuitem>          <menuitem label="业务逻辑层实现" >            <submenuitem label="ASP开发王" data="a1"/>            <submenuitem label="JSP开发王" data="a2"/>            <submenuitem label="ASP.NET开发王(C#)" data="a3"/>            <submenuitem label="ASP.NET开发王(VB)" data="a4"/>            <submenuitem label="PHP开发王" data="a5"/>          </menuitem>          <menuitem label="www.baidu.com"/>        </root>      </mx:XML>           </mx:MenuBar></mx:Application>

热点排行