I do not know if it relates to your problem, but set data gets called
too often to do that much work.

 

In set data, store whatever data you need into local instance variables.
Call invalidateProperties().  Then do the work in commitProperties or
updateDisplayList or createChildren.   

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of markuswiegleb
Sent: Wednesday, January 07, 2009 4:32 PM
To: [email protected]
Subject: [flexcoders] set data in TreeItemRenderer creates branches
twice after reopening

 

Hello all,

this is my first post here :)

I'm working on a TreeItemRenderer and want to add a progressbar to the
branches that displays some average percentual data from the leafes.

------------------------------------------------------------------------
----------------------------
    public class TaskTreeRenderer extends TreeItemRenderer
    {
        protected var bar:ProgressBar;
        
        public function TaskTreeRenderer()
        {
            super();

        }
        
        override public function set data(value:Object):void
        {    
            super.data = value;
            if(TreeListData(super.listData).item.children){
                if(!bar) {
                      trace(className);
                      trace("added in
"+TreeListData(super.listData).label);
                      bar = new ProgressBar();
                      bar.mode = "manual";
                      addChild(bar);
                      
                }
            }

            if(TreeListData(super.listData).hasChildren) {
                setStyle("color", 0xff0000);
                setStyle("fontWeight", 'bold');
            }
            else {
                setStyle("color", 0x000000);
                setStyle("fontWeight", 'normal');
            } 
        }
    }
------------------------------------------------------------------------
----------------------------

This works fine when the tree is generated but as soon as you open a
branch, close it and reopen it again the "added in " message is traced a
second time and a progress bar with a black label appears at the bottom
of the opened branch. I tried to put the progressbargeneration in
createChildren( ) but I can't use
TreeListData(super.listData).hasChildren in that function, flex dislikes
it somehow. How can I handle it and why is that branch generatet twice?
if(TreeListData(super.listData).hasChildren) doesn't seem to be the
right filter in this case. I thougt about collecting the uniqe ID of the
treeitems an controlling the addChild(bar) this way but it seems to be a
clean solution.

Hopefully one of you guys that has the know-how can help me out

Markus Wiegleb

 

Reply via email to