Have you ever wondered if it was possible to change the folder icons in the Flash version of cftree? The answer is yes, with a little of workaround.
This example will show you how to change the opened/closed folder icon, the leaf icon, the icon of a specific node, and the default triangles that open and close nodes. Because we need to set the default values before the data is loaded, we cannot change the icons of an already loaded cftee, unless we change each of the nodes one by one.
Have you ever wondered if it was possible to change the folder icons in the Flash version of cftree? The answer is yes, with a little of workaround.
This example will show you how to change the opened/closed folder icon, the leaf icon, the icon of a specific node, and the default triangles that open and close nodes. Because we need to set the default values before the data is loaded, we cannot change the icons of an already loaded cftee, unless we change each of the nodes one by one.
Because of that, I will show it when it loads with data coming from Flash Remoting, so that I have the opportunity to change the icons before the tree gets its data.
We first need to define our icons:
A tree:
and then, on the onclick of a button, we set the default icons:
categories.setStyle("folderOpenIcon",folder_open.icon);
categories.setStyle("folderClosedIcon",folder.icon);
categories.setStyle("defaultLeafIcon",doc.icon);
categories.setStyle("disclosureOpenIcon", arrowDown.icon);
categories.setStyle("disclosureClosedIcon", arrow.icon);
That would change all the icons and arrows with our custom icons. If we want to change the icon of a specific node, we need to wait for the data to load. Therefore, if we get the data as described in CFTree populated with Flash remoting and XML, we would do the following right after setting the dataProvider of the tree:
categories.setIcon(categories.getTreeNodeAt(0),
_root.folder_home.icon,_root.folder_home.icon);
In this case, we are getting the root (index 0), but we could get any other node of the tree.