Tracy Spratt <tspratt@lariatinc.com> 의 아이디어입니다
<?xml version="1.0" encoding="utf-8"?>
<!-- Tree control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">
<mx:Script><![CDATA[
[Bindable]
public var _xmlData:XML;
public function initApp():void
{
_xmlData = <element eid="hello">
<element eid="world">
<element eid="123"/>
<element eid="graham"/>
<element eid="weldon">
<element eid="office">
<element eid="thing"/>
<element eid="boat"/>
<element eid="chair"/>
</element>
<element eid="person"/>
</element>
</element>
</element> ;
}//initapp
private function expandParents(xmlNode:XML):void
{
while (xmlNode.parent() != null) {
xmlNode = xmlNode.parent();
myTree.expandItem(xmlNode,true, false);
}
}//expandParents
private function findNodeById(sId:String):void
{
var xmllistDescendants:XMLList = _xmlData.descendants().(@eid == sId);
expandParents(xmllistDescendants[0]);
myTree.selectedItem = xmllistDescendants[0];
}//findNodeById
]]></mx:Script>
<mx:Panel title="Tree Control Example" height="75%" width="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:HBox>
<mx:TextInput id="tiId" text="boat" />
<mx:Button label="Find" click="findNodeById(tiId.text)" />
</mx:HBox>
<mx:Tree id="myTree" width="50%" height="100%" labelField="@eid"
showRoot="false" dataProvider="{_xmlData}" />
</mx:Panel>
</mx:Application>