package
{
import flash.display.DisplayObject;
import mx.collections.*;
import mx.controls.Image;
import mx.controls.treeClasses.*;
import mx.events.ListEvent;
public class MyImageItemRenderer extends TreeItemRenderer
{
[Bindable]
[Embed(source="index.jpg")]
private var exceptionIcon:Class;
private var exceptionImage:Image = new Image();
public function MyImageItemRenderer()
{
super();
}
private function tree_itemClick(evt:ListEvent):void
{
var item:Object = evt.currentTarget.selectedItem;
}
override public function set data(value:Object):void
{
super.data = value;
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if(super.data.@vis == true)
{
this.addChild(this.exceptionImage as DisplayObject);
if(super.data)
{
if(!(TreeListData(super.listData).hasChildren))
{
this.exceptionImage.x = super.label.x + super.label.textWidth + 5;
this.exceptionImage.y = 0;
this.exceptionImage.width = super.label.textHeight;
this.exceptionImage.height = super.label.textHeight;
this.exceptionImage.source = exceptionIcon;
}
}
}
}
}
}
{
import flash.display.DisplayObject;
import mx.collections.*;
import mx.controls.Image;
import mx.controls.treeClasses.*;
import mx.events.ListEvent;
public class MyImageItemRenderer extends TreeItemRenderer
{
[Bindable]
[Embed(source="index.jpg")]
private var exceptionIcon:Class;
private var exceptionImage:Image = new Image();
public function MyImageItemRenderer()
{
super();
}
private function tree_itemClick(evt:ListEvent):void
{
var item:Object = evt.currentTarget.selectedItem;
}
override public function set data(value:Object):void
{
super.data = value;
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if(super.data.@vis == true)
{
this.addChild(this.exceptionImage as DisplayObject);
if(super.data)
{
if(!(TreeListData(super.listData).hasChildren))
{
this.exceptionImage.x = super.label.x + super.label.textWidth + 5;
this.exceptionImage.y = 0;
this.exceptionImage.width = super.label.textHeight;
this.exceptionImage.height = super.label.textHeight;
this.exceptionImage.source = exceptionIcon;
}
}
}
}
}
}
No comments:
Post a Comment