Flex Tree 使用外部图片做ICON
package Unit{ import flash.events.Event; import flash.utils.Dictionary; import mx.containers.VBox; import mx.controls.Image; public class IconClass extends VBox { //字典,避免同一个ICON重复加载,出现闪屏 static public var alliconsimage:Dictionary = new Dictionary(); public function IconClass() { super(); this.addEventListener(Event.ADDED_TO_STAGE,onAddToStage); } public function onAddToStage(e:Event):void { if(alliconsimage[Object(this.parent).listData.item] == null) {//字典中没有该item的图标 alliconsimage[Object(this.parent).listData.item] = new Image(); alliconsimage[Object(this.parent).listData.item].source = Object(this.parent).listData.item.@icon.toXMLString();//加载 } //this.source = Object(this.parent).listData.item.@icon.toXMLString() if(this.numChildren==0)//没有添加过icon this.addChild(alliconsimage[Object(this.parent).listData.item]); } }}
?