<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Tree labelFunction="treeFun" x="10" y="10" width="199" height="327" id="tree" folderOpenIcon="@Embed(source='img/add_folder.png')"
defaultLeafIcon="@Embed(source='images/scroll_arrow_down_over.png')" creationComplete="load()" fontSize="14"
openEasingFunction="Bounce.easeOut" openDuration="500" dataTipFunction="tipFun" showDataTips="true">
</mx:Tree>
<mx:XML id="treeXMLSource">
<node label="grandFather">
<node label="father">
<node label="me">
<node label="son">
<node label="grandson">
<node label="greatGrandSon"/>
</node>
<node label="granddaughter"/>
</node>
<node label="daughter"/>
</node>
</node>
<node label="Uncle"/>
<node label="Aunt">
<node label="cousin"/>
<node label="cousin"/>
</node>
</node>
</mx:XML>
<mx:Script>
<![CDATA[
[Bindable]
[Embed(source="images/scroll_arrow_down_over.png")]
public var ico1:Class;
//加载树数据源
private function load():void
{
tree.dataProvider=treeXMLSource;
}
//labelFunction改变值
private function treeFun(item:XML):String{
return item.@label+"-"+"888";
}
//toolTip函数
private function tipFun(it:Object):String{
return it.@label;
}
]]>
</mx:Script>
</mx:Application>