Get selected label for Tree item
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> import flash.events.*; import mx.events.*; import mx.controls.*; private function changeEvt(event:Event):void { var theData:String = ""; if (event.currentTarget.selectedItem.@data) { theData = " Data: " + event.currentTarget.selectedItem.@data; } forChange.text = event.currentTarget.selectedItem.@label + theData; } private function itemOpenEvt(event:TreeEvent):void { forOpen.text = event.item.@label; } </mx:Script> <mx:Tree id="XMLtree1" width="150" height="170" labelField="@label" itemOpen="itemOpenEvt(event);" change="changeEvt(event);"> <mx:XMLListCollection id="MailBox"> <mx:XMLList> <node label="Doc" data="100"> <node label="Chapter 1" data="70" /> <node label="Chapter 2" data="10"> <node label="Section 1" data="2" /> <node label="Section 2" data="3" /> <node label="Section 3" data="0" isBranch="true" /> <node label="Section 4" data="5" /> </node> <node label="Pdf" data="15" /> <node label="Rdf" data="5" /> </node> </mx:XMLList> </mx:XMLListCollection> </mx:Tree> <mx:Label text="Change Event:" /> <mx:TextArea id="forChange" width="150" /> <mx:Label text="Open Event:" /> <mx:TextArea id="forOpen" width="150" /> </mx:Application>