3 Replies Latest reply on Jan 2, 2007 5:07 PM by ntsiii

    Item Renderers for Trees

    Pigg_Man
      Does anyone know what the function in the example below do? I've been doing flash 7 and 8 for 2 yrs and am trying to convert everything over to flex 2.0. I added the class below to an itemRenderer for a tree but can't figure out what the function do. I need to create 4 labels for a row and etc.... Please help


      public class TreeCellRenderer extends TreeItemRenderer {

      public function TreeCellRenderer () {
      super();
      }

      // Override the set method for the data property
      // to set the font color and style of each node.
      override public function set data(value:Object):void {
      super.data = value;
      /*if (TreeListData(super.listData) != null) {
      if(TreeListData(super.listData).hasChildren) {
      setStyle("color", 0xff0000);
      setStyle("fontWeight", 'bold');
      }
      else {
      setStyle("color", 0x000000);
      setStyle("fontWeight", 'normal');
      }
      }*/
      }

      // Override the updateDisplayList() method
      // to set the text for each tree node.
      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
      super.updateDisplayList(unscaledWidth, unscaledHeight);
      /*if(super.data) {
      if (TreeListData(super.listData)){
      // Is this current node a folder?
      if(TreeListData(super.listData).hasChildren) {
      /**
      * remember just because this renderer is used for a node call bob this time
      * doesnt mean it will be used for the node bob the next time you expand or
      * collpase the parent tree node.
      * There are other ways around this but for this simple example I just wanted
      * to show how to add things
      **/
      // if there is no button in this renderer add one
      /* if (btn_refresh == null){
      btn_refresh = new TreeRefreshButton();
      btn_refresh.x = this.width-btn_refresh.width;
      addChild(btn_refresh);
      }
      // set the current node inside the refresh button
      btn_refresh.Node = TreeListData(super.listData);
      // Ok its not a folder so remove that button
      }else{
      if (btn_refresh != null)
      this.removeChild(btn_refresh);
      }
      }
      }*/
      }
      }