Thanks for the posts, I modified the script at the given link, 
here's the [working] results...

Note that the "rowHeight" property of the Tree also needed to be set 
to a larger value (60 in this case).

package MyTreeRenderer
{
        import mx.controls.treeClasses.TreeItemRenderer;
        import mx.controls.Image;
        import mx.controls.Tree;
        import mx.controls.treeClasses.*;
        import mx.collections.*;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.util.trace;
        
        public class MyTreeItemRenderer extends TreeItemRenderer
        {
                // myImage: holds the image we are adding to the 
tree nodes
        protected var myImage:Image;
        
        // set image properties
        private var imageWidth:Number   = 60;
            private var imageHeight:Number      = 60;
            
            // set the margin between the image we are adding, and 
the label
                private var imageToLabelMargin:Number = 2;
                
                // show default branch icon?
                private var showDefaultBranchIcon:Boolean       = 
false;
                // show default leaf icon?
                private var showDefaultLeafIcon:Boolean         = 
false;

        public function MyTreeItemRenderer() 
                {
                        super();

                        // InteractiveObject variables.
                        mouseEnabled = false;
                }
                
                public function openBranch(evt:Event):void
                {
                        // get the TreeListData
                        var myListData:TreeListData = TreeListData
(this.listData);
                        
                        // get the selected node
                        var selectedNode:Object = myListData.node;
                        
                        // get the tree that owns us
                        var theTree:Tree = Tree(myListData.owner);
                        
                        // find out if the selected branch is 
already open
                        var isBranchOpen:Boolean = theTree.getIsOpen
( selectedNode );
                        
                        // if the selected branch is open, let's 
close it
                        // and if it's closed, let's open it
                        var isBranchOpen:Boolean = isBranchOpen ? 
false : true;
                        theTree.setIsOpen( selectedNode, 
isBranchOpen, true, false );
                }
                
                override protected function createChildren():void
                {
                // create a new image() to hold the image we'll add 
to the tree item
                        myImage = new Image();
                        
                        myImage.width = imageWidth;
                        myImage.height = imageHeight;
                        myImage.setStyle
( "verticalAlign", "middle" );

                        // and apply it to the tree item
                        addChild(myImage);
                        
                        // add the event listener to the whole tree 
item
                        // this will let us click anywhere on the 
branch item to expose the children of this branch
                        addEventListener( MouseEvent.CLICK, 
openBranch  );
                        
                        super.createChildren();
            }   
            
                override public function set data(value:Object):void
                {
                                super.data = value;
                                if(this.parent == null)
                                        return void;
                                // get the tree that owns us
                                var _tree:Tree = Tree
(this.parent.parent);//.parent);
                                
                                // if the current node is a branch 
node
                                if(TreeListData
(super.listData).hasChildren)
                                {
                                        // set styles...
                                    setStyle("color", 0xff0000);
                                    setStyle("fontWeight", 'bold');

                                    // if we don't want to show the 
default branch icons, let's empty them
                                    if( !showDefaultBranchIcon )
                                    {
                                        _tree.setStyle
("folderClosedIcon", null);
                                        _tree.setStyle
("folderOpenIcon", null);
                                    }
                                }
                                else
                                {
                                        // if we are in here, then 
the current node is a leaf node
                                        
                                        // set styles...
                                    setStyle("color", 0x000000);
                                    setStyle("fontWeight", 'normal');
                                    
                                    // if we don't want to show the 
default leaf icons, let's empty them
                                    if( !showDefaultLeafIcon )
                                    {
                                        _tree.setStyle
("defaultLeafIcon", null);
                                    }
                                }
                                
            }
                
           override protected function updateDisplayList
(unscaledWidth:Number,
                                                                
                                                  
unscaledHeight:Number):void
           {
                        super.updateDisplayList(unscaledWidth, 
unscaledHeight);
                if(super.data)
                {
                        // if the current node is a branch
                            if(TreeListData
(super.listData).hasChildren)
                            {
                                // get the current node and it's 
children as XMLList
                                var currentNodeXMLList:XMLList = new 
XMLList(TreeListData(super.listData).item);
                                
                                // get the number of children under 
the current node
                                var numOfImmediateChildren:int = 
currentNodeXMLList[0].children().length();
        
                                        // set the image to be 
displayed in the branches
                                myImage.source = 
[EMAIL PROTECTED];//branchImage;
                                
                                // set the label text
                                super.label.text =  TreeListData
(super.listData).label + "(" + numOfImmediateChildren + " teams)";
                                
                            } else {
                                // if we are in here, then the 
current node is a leaf node
                                
                                        myImage.source =  
[EMAIL PROTECTED] //leafimage;
                            }
                            // reset the position of the image to be 
before the label
                            myImage.x = super.label.x;
        
                            // reset the position of the label to be 
after the image, plus give it a margin
                            super.label.x = myImage.x + imageWidth + 
imageToLabelMargin;
                        }
            }
        }
}





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to