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