CheckboBoxTree循环判断选中的节点

本文章用到checkboxTree的渲染器,请到我的博客查看:
http://blog.csdn.net/xuhuanchao/archive/2009/11/25/4873725.aspx

 

 

 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Tree labelFunction="treeFun" x="10" y="10" width="199" height="327" id="tree" folderOpenIcon="@Embed

(source='img/add_folder.png')"
    defaultLeafIcon="@Embed(source='images/scroll_arrow_down_over.png')" creationComplete="load()"

fontSize="14" itemClick="choose(event)"
    openEasingFunction="Bounce.easeOut" openDuration="500" itemRenderer="com.checkboxRenderer">
 </mx:Tree>

 <mx:XML id="treeXMLSource">
  <node label="grandFather">
   <node label="father">
    <node label="me">
     <node label="son">
      <node label="grandson">
       <node label="greatGrandSon"/>
      </node>
      <node label="granddaughter"/>
     </node>
     <node label="daughter"/>
    </node>
   </node>
   <node label="Uncle"/>
   <node label="Aunt">
    <node label="cousin"/>
    <node label="cousin"/>
   </node>
  </node>

 </mx:XML>
  <mx:Script>
  <![CDATA[
   //tree项目点击事件,判断选中的值
   private function choose(event:ListEvent):void
   {
    CursorManager.setBusyCursor();
    
    var xmll:XMLList=treeXMLSource.children();
    findChecked(xmll);
    CursorManager.removeBusyCursor();
   }
                        //递归查询
   private function findChecked(xmllist:XMLList):void{
    for(var i:int=0;i<xmllist.length();i++)
    {
     if(xmllist[i].@state=="checked")
     {
      Alert.show(xmllist[i].@label);
      //break;
     }    

  if(xmllist[i].hasComplexContent()){//检查是否是复杂数据
       findChecked(xmllist[i].children());
     }
     
     
    }
   }
  ]]>
 </mx:Script>
</mx:Application>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值