2 Replies Latest reply on May 21, 2010 10:17 AM by -skitch-

    Flex SDK 3.4 Tree Item Renderer Root Folder displays Tooltip for Child

    -skitch- Level 1

      I have a Flex Tree that uses a custom item renderer.  The item renderer extends Tree Item Renderer and I add my button in commit properties (since the data is dynamic) and I use update displaylist to move it to the right position.  I set the button to be visible on rollover and make the icon invisible. On rollout I reverse that logic.

       

      When I have my item renderer add the button, it causes only one problem and it seems to be under certain conditions:

       

      - Single root folder for the tree

      - Upon opening the tree, the root folder displays the tool tip for the last child in the tree

       

      Any idea why the tooltip comes up?

       

      public function AssetTreeItemRenderer ()
              {
                  super();
                  addEventListener(MouseEvent.ROLL_OVER, onItemRollover);
                  addEventListener(MouseEvent.ROLL_OUT, onItemRollout);
                  addEventListener(ToolTipEvent.TOOL_TIP_SHOWN, toolTipShown);
                  addEventListener(ToolTipEvent.TOOL_TIP_CREATE, onCreateToolTip);
              }
             
              //--------------------------------------------------------
              // OVERRIDEN FUNCTIONS
              //--------------------------------------------------------
              /**
               * override createChildren
               */
              override protected function commitProperties():void {
                  super.commitProperties();
                 
                  if(data is IAsset) {
                      if(playBtn === null) {
                          playBtn = new Button();
                          playBtn.styleName = "previewPlayButton";
                          playBtn.toolTip = "Play";
                          playBtn.width = icon.width + 2;
                          playBtn.height = icon.height + 2;
                          playBtn.visible = false;
                          playBtn.addEventListener(MouseEvent.CLICK, onPlayBtnClick);
                          addChild(playBtn);
                      }
                  } else {
                      if(playBtn !== null) {
                          removeChild(playBtn);
                          playBtn = null;
                      }
                  }
              }
             
              /**
               * override updateDisplayList
               * @param Number unscaledWidth
               * @param Number unscaledHeight
               */
              override protected function updateDisplayList(unscaledWidth:Number,
                                                            unscaledHeight:Number):void
              {
                  super.updateDisplayList(unscaledWidth, unscaledHeight);
                 
                  //Move our play button to the correct place
                  if(super.data && playBtn !== null)
                  {
                      playBtn.x = icon.x;
                      playBtn.y = icon.y;
                  }
              }