<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="/mxml/2009"
xmlns:s="library:///flex/spark"
xmlns:mx="library:///flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
]]>
</fx:Script>
<fx:Declarations>
<!-- Put non-visual elements (such as services, value objects) here -->
<fx:XML >
<root>
<node label="CI configuration item" iconName="">
<node label="Resource" iconName="">
<node label="Hardware Resource" iconName="">
<node label="Hardware Device" iconName="">
</node>
<node label="Hardware Module" iconName="">
<node label="port" iconName="">
</node>
</node>
</node>
</node>
</node>
<node label="Dictionary" iconName="">
</node>
</root>
</fx:XML>
</fx:Declarations>
<mx:Tree left="5" top="5" bottom="5" width="150" dataProvider="{treeData}"
showRoot="false"
labelField="@label"
itemRenderer="">
</mx:Tree>
</s:Application>
package
{
import .*;
import .*;
import ;
import .*;
import .*;
import ;
/*
* ICON Tree's renderer
*/
public class IconTreeRenderer extends TreeItemRenderer
{
protected var myImage:ImageRenderer;
private var imageWidth:Number = 16;
private var imageHeight:Number = 16;
private static var defaultImg:String = "";
public function IconTreeRenderer ()
{
super();
}
override protected function createChildren():void
{
();
myImage = new ImageRenderer();
= defaultImg;
=imageWidth;
=imageHeight;
( "verticalAlign", "middle" );
addChild(myImage);
}
// Dynamically set tree's node icon by overwriting data method
override public function set data(value:Object):void
{
= value;
var imageSource:String=value.@();
if(imageSource!="")
{
=imageSource;
}else{
=defaultImg;
}
}
//Hide the original icon and set its coordinates
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
(unscaledWidth, unscaledHeight);
if( !=null)
{
if ( != null)
{
= ;
= 2;
=false;
}
else
{
= ;
= 2;
= + + 17;
}
}
}
}
}
package
{
import ;
public class ImageRenderer extends Image
{
private var defaultURL:String = "assets/icon/";
public var iconName:String;
public function ImageRenderer()
{
super();
}
override public function set source(url:Object):void{
= defaultURL + url;
iconName = url as String;
}
}
}