0 Replies Latest reply on Jun 5, 2007 2:29 AM by romanczar

    TreeItemRenderer with additional functionality

    romanczar Level 1
      I would like to have a tree with a custom itemrenderer like this

      // itemRenderers/tree/myComponents/MyTreeItemRenderer.as
      import mx.controls.treeClasses.*;
      import mx.collections.*;
      import mx.controls.Image;
      import flash.display.DisplayObject;
      import flash.events.MouseEvent;
      import mx.controls.Button;

      public class ProfileTreeItemRenderer extends TreeItemRenderer

      private var deleteImage:Image = new Image();

      // Define the constructor.
      public function ProfileTreeItemRenderer() {

      addEventListener(MouseEvent.CLICK, this.deleteIconClickHandler);
      this.addChild(this.deleteImage as DisplayObject);

      // 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;

      // Override the updateDisplayList() method
      // to set the text for each tree node.
      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
      this.deleteImage.x = unscaledWidth - 20;
      this.deleteImage.y = 0;
      this.deleteImage.width = 18;
      this.deleteImage.height = 18;

      this.deleteImage.buttonMode = true;
      this.deleteImage.useHandCursor = true;

      this.deleteImage.source = "images/icons/icon_delete.png";

      super.updateDisplayList(unscaledWidth, unscaledHeight);


      private function deleteIconClickHandler(event:MouseEvent):void

      Works finde. Display a "trash" icon at the end of each item. but I can't click on the item and communicate with any function, neither included in the itemRenderer, nor parentDocument.xyz

      Can anybody please help a little bit?