반응형
TreeTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:XMLList id="treedata">
<node label="javaCourse">
<node label="teamA" data="select member">
<node label="kim" data="☎ 268-4356"/>
<node label="kang" data="☎ 345-0564"/>
<node label="jung" data="☎ 567-9784"/>
</node>
<node label="teamB" data="select member">
<node label="yoo" data="☎ 875-2345"/>
<node label="shin" data="☎ 654-4563"/>
</node>
</node>
</mx:XMLList>
<mx:Panel width="300" height="200" layout="absolute" verticalCenter="0" horizontalCenter="0">
<mx:HDividedBox x="0" y="0" width="280" height="160">
<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.@data}"/>
</mx:HDividedBox>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
[Bindable]
public var selectedNode:XML;
// Event handler for the Tree control change event.
public function treeChanged(event:Event):void{
selectedNode = Tree(event.target).selectedItem as XML;
}
]]>
</mx:Script>
</mx:Application>
반응형