2 Replies Latest reply on Mar 18, 2009 2:29 AM by Sandi

    Color tree icon

    Sandi
      Hi Flex experts,

      I'm writing here, because I can't get an answer by myself. I use swc file as reference where I put all icons inside. Now, I want to color all leaf icons (in red for an example). I'm trying to do it in custom treeitemrenderer in set data:

      public class CustomTreeItemRenderer extends TreeItemRenderer
      {
      [Embed(skinClass="Tree_defaultLeafIcon")]
      private var DefaultLeafIcon:Class;

      override public function set data(value:Object):void
      {
      super.data = value;
      var _tree:Tree = Tree(this.parent.parent);
      if(!TreeListData(super.listData).hasChildren)
      {
      var mc:MovieClip = new DefaultLeafIcon();
      var colorTransform:ColorTransform = mc.transform.colorTransform;
      colorTransform.color = 0xFF0000;
      mc.transform.colorTransform = colorTransform;
      _tree.setStyle('defaultLeafIcon', mc);
      }
      }
      }
      The last line does not compile because mc in not class. But I'm not able to do it differently. Can somebody show me how can I do it, please?
        • 1. Re: Color tree icon
          Gregory Lafrance Level 6
          I think you need to make mc a separate class, because I think setStyle is looking for a class name, not an instance name. So do whatever you need done in the constructor, or in methods called by the constructor.
          • 2. Re: Color tree icon
            Sandi Level 1
            quote:

            Originally posted by: Greg Lafrance
            I think you need to make mc a separate class, because I think setStyle is looking for a class name, not an instance name. So do whatever you need done in the constructor, or in methods called by the constructor.


            Greg, thanks for your answer. But it's just getting worse. The color should come as a parameter from data. Maybe this is not right approach. Any suggestions?