1 Reply Latest reply on Feb 22, 2007 2:43 AM by ctzn99

    Tree Control

    nprzybylo Level 1
      I am trying to set an intial selection on my Tree control under the creationComplete event for the control. I figured myTree.selectedIndex = 0; would do the trick, but although it highlights the item, I cannot get any information back. For instance, if I have the following statements in the event handler:

      myTree.selectedIndex = 0;

      The first element is highlighted, but it will not expand, and I can't get any other information about the selection. Any advice would by greatly appreciated.
        • 1. Re: Tree Control
          ctzn99 Level 1
          I just had this same problem the other day... the trick is that everything is happening asych so basically (sic) the expandItem method gets called so fast that the index on the tree isn't set yet. So, you can use the built in callLater function like so... (note: i made a helper expand function because it's easier and neater than trying to pass the expandItem parameters into callLater's params array object.)

          myTree.selectedIndex = 0;

          then the helper function is just
          private function expandRoot():void
          myTree.expandItem(myTree.selectedItem, true);