I’m making a tree like menu structure. It is already a hacky business but now I encountered another problem. And I have no clue where it is happening and if I do something wrong or Flex is messing it up.
I have a Tree component that uses a tree renderer to render the items. In this tree renderer I determine if it has children and style it by setting the left position and adding an icon.
If you open, close, open “test 2” in the example under this paragraph you see that the + sign icon is changing position. But the styling function (called init() in treeItemRenderer) that is setting that + icon is only called once. I get the idea that he is mirroring the items after the click. I have the source here. I hope some one else knows how to solve this.
Example
Source is enabled, but I’m getting a scary hamster 😉
Damn those hamsters!
I disabled the source and uploaded it to here. And I added some links in the post 😉 First time I use a plugin to add a swf inside a post.
I see what you are doing….. never use data in a creationComplete handler or what so ever.
In treeItemRenderer.mxml move this part:
if (data.isChild as Boolean){
this.SecondCanvas.x = (data.depth + 1) * 15;
this.mainLabel.setStyle(“left”, 5);
this.mainImage.visible = false;
}else{
if (data.depth < 1){
this.mainLabel.setStyle(“fontWeight”,”bold”);
}
this.SecondCanvas.x = (data.depth) * 25;
if (data.children == null){
this.mainImage.visible = false;
//this.SecondCanvas.x =;
//this.mainLabel.x = 0;
}else{
this.mainLabel.setStyle(“left”, 19);
this.mainImage.visible = true;
//this.SecondCanvas.x = (data.depth + 1) * 20;
}
}
To:
override public function set data
Also you start that with a capital letter….. so it would be TreeItemRenderer….mxml will be translated to a actual class.
Thank you that did the trick. I also found the solution by just calling that code also on Click and Change event But this is cleaner
As long as it is working for ya! 😉