<mx:XML> <mx:XMLList> 的应用

1.<mx:XML>在<mx:Tree>中的使用,存储数据(labelField表示显示xml数据中label的值。showRoot为false表示不显示要结点

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
 <mx:Panel x="109" y="65" width="280" height="300" layout="absolute" title="使用XML组件">
  <mx:Tree x="10" y="35"  id="tree2" width="218" height="260"  showRoot="false" labelField="@label">
   <mx:dataProvider>
    <mx:XML id="XMLData">
     <menus>
      <node label="Mail">
       <node label="Inbox"/>
       <node label="Personal Folder">
        <node label="Demo"/>
        <node label="Personal"/>
        <node label="Saved Mail"/>
        <node label="bar"/>
       </node>
       <node label="Calendar"/>
       <node label="Sent"/>
       <node label="Trash"/>
      </node>
     </menus>
     
    </mx:XML>
    
   </mx:dataProvider>
  </mx:Tree>
 </mx:Panel>
 
</mx:Application>

2.<mx:XMLList>的应用,存储数据 (labelField表示显示xml数据中id的值)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" horizontalAlign="left">
 <mx:states>
  <mx:State name="index1">
   <mx:AddChild position="lastChild">
    <mx:VBox id="myVBox1" x="{myMenuBar.x}" y="{myMenuBar.y+myMenuBar.height}"
     width="{myMenuBar.width}" height="248" backgroundColor="#ffffff"
     backgroundAlpha="0.5">
    </mx:VBox>
   </mx:AddChild>
  </mx:State>
  <mx:State name="index2">
   <mx:AddChild position="lastChild">
    <mx:VBox id="myVBox2" x="{myMenuBar.x}" y="{myMenuBar.y+myMenuBar.height}"
     width="{myMenuBar.width}" height="248" backgroundColor="#f5e531"
     backgroundAlpha="0.5">
     
    </mx:VBox>
   </mx:AddChild>
  </mx:State>
 
 </mx:states>
 <mx:MenuBar x="98" y="24" id="myMenuBar" dataProvider="{myXMLList}" labelField="@id" width="293" change="menuClickHandle(event)"></mx:MenuBar>
 
 <mx:XMLList id="myXMLList" >
  <menuitem id="Menu1">
   <menuitem id="SubMenu1" type="radio" groupName="one"/>
   <menuitem id="SubMenu2" type="radio" groupName="one"/>
  </menuitem>
  <menuitem id="Menu2">
   
  </menuitem>
  <menuitem id="Menu3">
   
  </menuitem>
  <menuitem id="Menu4">
   <menuitem id="SubMenu3" type="radio" groupName="two"/>
   <menuitem id="SubMenu4" type="radio" groupName="two"/>
   <menuitem id="SubMenu5" type="radio" groupName="two"/>
  </menuitem>
 </mx:XMLList>
 
 <mx:Script>
  <![CDATA[
   import mx.events.MenuEvent;
   private function menuClickHandle(e:MenuEvent):void{
    if(e.label=="SubMenu1")
     currentState="index1";
    else if(e.label=="SubMenu2")
     currentState="index2";
    else if(e.label=="SubMenu3")
     currentState="index3";
    else if(e.label=="SubMenu4")
     currentState="index4";
    else if(e.label=="SubMenu5")
     currentState="index5";
   }
   
  ]]>
 </mx:Script>
  
</mx:Application>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值