Strange behaviour of Tree component

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.


This movie requires Flash Player 9

Author Bio


  1. Maikel Sibbald - May 12, 2009

    Source is enabled, but I’m getting a scary hamster 😉

  2. Maikel Sibbald - May 21, 2009

    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;
    if (data.depth < 1){
    this.SecondCanvas.x = (data.depth) * 25;
    if (data.children == null){
    this.mainImage.visible = false;
    //this.SecondCanvas.x =;
    //this.mainLabel.x = 0;
    this.mainLabel.setStyle(“left”, 19);
    this.mainImage.visible = true;
    //this.SecondCanvas.x = (data.depth + 1) * 20;


    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.

  3. Maikel Sibbald - May 22, 2009

    As long as it is working for ya! 😉

Leave a reply