5 Replies Latest reply on Jul 1, 2011 5:16 AM by shawninreach

    TabbedViewNavigator, issue with removeAll

    cfjedimaster Level 3

      I've got a simple TabbedViewNavigator with 2 tabs. After an event, I want to remove all the tabs and add new ones. I tried this code:

       

      public function doIt():void {

      trace('called');

      this.tabbedNavigator.removeAll();

       

      var vn1:ViewNavigator = new ViewNavigator();

      vn1.firstView = views.HomeView;

      vn1.label = "Home";

      this.tabbedNavigator.addItem(vn1);

      }

      Everything works fine at the removeAll. When I do addItem, I get this error:
      RangeError: Index '1' specified is out of bounds.
      at spark.components::TabbedViewNavigator/set selectedIndex()[E:\dev\trunk\frameworks\projects\mobilecomponents\src\spark\components\Ta bbedViewNavigator.as:1239]
      at spark.components::TabbedViewNavigator/addItemAt()[E:\dev\trunk\frameworks\projects\mobile components\src\spark\components\TabbedViewNavigator.as:1379]
      at spark.components::TabbedViewNavigator/addItem()[E:\dev\trunk\frameworks\projects\mobileco mponents\src\spark\components\TabbedViewNavigator.as:1332]
      at LoginRegisterExample/doIt()[C:\Users\Raymond\Adobe Flash Builder 4.5\LoginRegisterExample\src\LoginRegisterExample.mxml:19]
      at views::LoginView/testClick()[C:\Users\Raymond\Adobe Flash Builder 4.5\LoginRegisterExample\src\views\LoginView.mxml:10]
      at views::LoginView/___LoginView_Button1_click()[C:\Users\Raymond\Adobe Flash Builder 4.5\LoginRegisterExample\src\views\LoginView.mxml:19]
      I also tried replacing removeAll with two removeItemAt(0) calls (I had 2 tabs). Again, that code worked - both tabs went away, but i got the same error when I tried to add an item. I also tried addItemAt(0).