<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
[Bindable]public var selectedNode:Object;
public function treeChanged(event:Event):void {
selectedNode=Tree(event.target).selectedItem;
}
]]>
</mx:Script>
<mx:XMLList id="treeData">
<node label="我的邮箱">
<node label="收件箱">
<node label="家书"/>
<node label="朋友"/>
<node label="商务"/>
</node>
<node label="发件箱">
<node label="公务"/>
<node label="私人"/>
</node>
<node label="垃圾邮件"/>
</node>
</mx:XMLList>
<mx:Panel title="树结构控件示例" height="75%" width="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:HDividedBox width="100%" height="100%">
<mx:Tree id="myTree" width="50%" height="100%" labelField="@label"
showRoot="false" dataProvider="{treeData}" change="treeChanged(event)"/>
<mx:TextArea height="100%" width="50%"
text="所选项目: {selectedNode.@label}"/>
</mx:HDividedBox>
</mx:Panel>
</mx:Application>