代码:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > <mx:Script> <![CDATA[ import mx.collections.XMLListCollection; [Embed(source="assets/max_over.gif")] //这是图片的相对地址 [Bindable] public var OKicon:Class; [Embed(source="assets/close_over.gif")] //这是图片的相对地址 [Bindable] public var NOicon:Class; //设置不同图表 private function iconFun(item:Object):* { var xml:XML = item as XML; if(xml.attribute("bool") == true) return OKicon; else if(xml.attribute("bool") == false) return NOicon; } ]]> </mx:Script> <mx:XMLListCollection id="datatree" > <mx:source> <mx:XMLList> <node label="NO1" bool="false"> <node label="NO11" bool="false"> <node label="NO111" bool="false"/> </node> <node label="NO22" bool="true"/> </node> <node label="NO2" bool="true"> <node label="NO11" bool="false"> <node label="NO111" bool="false"/> </node> <node label="NO22" bool="true"> <node label="NO222" bool="false"/> </node> </node> </mx:XMLList> </mx:source> </mx:XMLListCollection> <mx:Tree id="tree" y="40" width="100%" height="100%" fontFamily="Arial" fontSize="12" dataProvider="{datatree}" labelField="@label" iconFunction="iconFun" /> </mx:Application>
原文地址:http://oliwen.blog.163.com/blog/static/38057532200821234231321/
|