Asign icons to Tree control in flex.

There are icons asigned to Tree control for folderOpen, folderClose and for leaf nodes.The folder icon for folder open and close and one leaf icon.What if i want to change this default icons of Tree control.. its simple !.

The properties we got to use here is that:

folderOpenIcon -> for folder Open.

folderClosedIcon ->for folder close.

defaultLeafIcon ->for leaf icon.

Example:

<mx:Tree x=”10″ y=”10″ folderOpenIcon=”@Embed(’images/fopen’)” ></mx:Tree>

Similarly for other properties..!

2 Responses to “Asign icons to Tree control in flex.”

  1. Marcus Says:

    Is it possible to use different folderOpenIcon’s / folderClosedIcon’s in a tree?

    Can I override this behavior programmtically?

  2. kumargandhi Says:

    HI MARCUS,
    its possible ,first define the icons of type Class and assign them to nodes programatically as u required and setItemIcon is the methos we have to use of Tree class.

    Example:
    [Embed("assets/folder_table.png")]
    private var FolderIcon1:Class;

    [Embed("assets/folder_user.png")]
    private var FolderIcon2:Class;

    [Embed("assets/folder_wrench.png")]
    private var FolderIcon3:Class;

    //These are the folder icons iam assaining to three folders.with the code below.

    private function init():void {
    var nodeOne:XML = xmlListColl.getItemAt(0) as XML;
    tree.setItemIcon(nodeOne, FolderIcon1, FolderIcon1);
    // similarly set for other folders. here xmlListColl is my XML List for Tree.

    }

    END:

    Try it, will work.or comment me.

Leave a Reply