hai,
    thanks.. I tried something like the following and it didnt work.. can you pls tell where i have gone wrong..
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
[Embed(bookIcon.source="assets/amway/numbergif/i.gif")]
var bookIcon : String;
function iconFunc(item)
{
  if (item.label == "Beauty and Body") return bookIcon;
  else 
  myTree.getStyle("defaultLeafIcon");
}
]]>
</mx:Script>
<mx:Panel height="100%" width="40%" title="CATALOG">
           <mx:Tree id="myTree" height="100%" width="100%"  defaultLeafIcon="@Embed('assets/online1.png')" folderClosedIcon="@Embed('assets/offline.png')" folderOpenIcon="@Embed('assets/online.png')" disclosureOpenIcon="@Embed('assets/amway/numbergif/a.gif')" disclosureClosedIcon="@Embed('arrw08_07a.gif')">
   <mx:dataProvider>
      <mx:XML>
   
           <node label="Product">
             <node label="Books"/>
               <node label="Grocery"> 
                     <node label="Food" />
             <node label="Kitchen"/>
    <node label="Home"/>
    </node>
    <node label="Home Essentials"> 
          <node label="Home Care" /> 
              </node>
         </node>
      </mx:XML>
   </mx:dataProvider>
</mx:Tree>
    </mx:Panel>
</mx:Application>

Matt Chotin <[EMAIL PROTECTED]> wrote:

iconFunction should return the symbol that should be used as the icon.  So you would embed your image and then return it as appropriate:

 

[Embed(source=”myBookIcon.jpg”)]

var bookIcon : String;

 

function iconFunc(item)

{

  if (item.label == “books”) return bookIcon;

  else return someOtherIconName;

}

 

If you want to use the original icons if yours isn’t appropriate you can get the defaultLeafIcon, folderOpenIcon, and folderClosedIcon (myTree.getStyle(“defaultLeafIcon”))

 

HTH,

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of nithya karthik
Sent: Wednesday, May 11, 2005 2:41 AM
To: flexcoders
Subject: [flexcoders] HOw to change the foldericon of the tree dynamically acording to some condition?

 

hai,

      I'd like to know how to change the folderopen and folderclose icon of a tree control dynamically according to some condition (say when the node label is "books", i want the folderopenIcon to be 'books.png'......)

 

help me with some code for this....

 

How should i use the IconFuntion in a tree?

 

thanks,

nithya


Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now


Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now

Yahoo! Groups Links

Reply via email to