Using the setItemIcon() method for Tree control
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
[Bindable]
[Embed(source="logo.jpg")]
public var iconSymbol1:Class;
[Bindable]
[Embed(source="logo.jpg")]
public var iconSymbol2:Class;
private function setIcons():void {
myTree.setItemIcon(myTree.dataProvider.getItemAt(0),iconSymbol1, iconSymbol2);
myTree.setItemIcon(myTree.dataProvider.getItemAt(1),iconSymbol2, null);
}
</mx:Script>
<mx:Tree id="myTree" labelField="@label" showRoot="false" width="160" initialize="setIcons();">
<mx:XMLList>
<node label="New">
<node label="HTML Document" />
<node label="Text Document" />
</node>
<node label="Close" />
</mx:XMLList>
</mx:Tree>
</mx:Application>
Related examples in the same category