1 Reply Latest reply on Jul 14, 2006 5:33 PM by njadobe

    Problem with TabNavigator and removing childs

    Bart Vanhulle
      I'm working on an application which uses states. One of the states implements a TabNavigator component where I add and remove childs (other custom mxml components) on the fly. This adding and removing works fine. But when I change the state of the application and go back to the TabNavigator state the application freezes. If I leave 1 child in the TabNavigator and switch states and eventually go back it works just fine. But when all childs are removed it gets stuck. I have tried to remove the last child in different ways but they were all unsuccesful. This is how I currently do it:

      public function removeNavChild(cid:String) : void {
      var childToDelete :DisplayObject = navigator.getChildByName(cid);
      if ( childToDelete ) {
      if ( navigator.numChildren == 1 ) {
      navigator.removeChild(childToDelete );
      private function quit() : void {
      Application.application.currentState = "login";

      Am I missing something here or is this another bug? Any input would be highly appreciated.

        • 1. Problem with TabNavigator and removing childs
          Hi Biebel37,

          I was able to get a runtime error with a test app I wrote doing something similar to what you described. I think what you're doing should be legal, so it may be an SDK bug, but I'll file it and see if the SDK team agrees :)

          One workaround that might work for you would be to make it so that instead of creating the TabNavigator in a given state (using AddChild), you put it in the base state, but set visible="false". Then, in the state where you want it to appear, use <SetProperty target="{nav}" name="visible" value="true"/>. (Depending on how you're doing your layout, you may need to set includeInLayout="false" in the base state and set it to true in the other state as well.) In my test app, this avoids the runtime error.


          Flex Builder team