<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.events.FlexEvent; import mx.events.ListEvent; [Bindable] private var arr:ArrayCollection=new ArrayCollection(); protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void { arr=new ArrayCollection(); arr.addItem({label: "第一章",children: "还不错哦",data: "哈哈"}); arr.addItem({label: "第二章",data: "好样的",children: [{label: "月亮",data: 111},{label: "太阳",data: 222},{label: "火星",data: 333}]}); arr.addItem({label: "第三章",data: "嗯嗯",children: "美国是垃圾"}); } protected function tree1_changeHandler(event:ListEvent):void { if (tree.selectedItem.hasOwnProperty("data")) { trace(tree.selectedItem.data); } else { trace(tree.selectedItem); } } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> <fx:XMLList id="treeData"> <node label="Mail Box"> <node label="123213123123"/> </node> <node label="InBox"> <node label="12312312312312"/> <node label="123555555652312312"/> <node label="1231236555555512312"/> </node> </fx:XMLList> </fx:Declarations> <mx:Tree id="tree" x="98" y="19" change="tree1_changeHandler(event)" width="529" height="450" dataProvider="{arr}" labelField="label"> </mx:Tree> </s:WindowedApplication>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。