5 Replies Latest reply on Dec 14, 2007 1:42 AM by Sreenivas R

    Tree skinning

    davidyn
      Hi,

      I created Tree component with XML data provider.

      I want the open brunch and leafs have a different back-color (some dark blue for the brunch and some pale blue for the leafs).

      the Tree-class properties includ only select/non-select styling.

      I need a hint.

      Thanks all
        • 1. Re: Tree skinning
          ntsiii Level 3
          You can do almost anything in a custom TreeItemRenderer.

          I have an example on www.cflex.net. Search for Tree itemRenderer

          Tracy
          • 2. Re: Tree skinning
            davidyn Level 1
            I tried to manage the TreeItemRenderer - with no luck.

            I cant find what property or method changes the item's backgroung color.

            maybe I need more than a hint....

            Help everybody!

            Thank,

            David.
            • 3. Re: Tree skinning
              Sreenivas R Adobe Employee
              backgrouncolor is a style. Use setStyle to change it.
              • 4. Re: Tree skinning
                davidyn Level 1
                Thanks Sreenivas,
                But where can I define the backgroundColor for a specific item?

                (ahhhh, Im going mad. maybe I'll just create my owm component, it takes more time but keeps me sane.)
                :) :( :\
                • 5. Re: Tree skinning
                  Sreenivas R Adobe Employee
                  Here is a sample code

                  package
                  {

                  import mx.controls.treeClasses.TreeItemRenderer;
                  import mx.controls.treeClasses.TreeListData;
                  import flash.display.SpreadMethod;
                  import flash.display.Sprite;
                  import flash.display.Graphics;

                  public class CustomItemRenderer extends TreeItemRenderer
                  {
                  var background:Sprite;

                  override protected function createChildren():void
                  {
                  super.createChildren();
                  background = new Sprite;
                  addChildAt(background, 0);
                  }

                  override protected function updateDisplayList (unscaledWidth:Number,
                  unscaledHeight:Number):void
                  {
                  super.updateDisplayList(unscaledWidth, unscaledHeight);
                  var gc:Graphics = background.graphics;
                  gc.clear();
                  if (TreeListData(listData).hasChildren)
                  gc.beginFill(0x0000FF, 0.5);
                  else
                  gc.beginFill(0x000088, 0.5);

                  gc.drawRect(0,0, unscaledWidth, unscaledHeight);
                  gc.endFill();
                  }
                  }

                  }