Skip navigation
cfjedimaster
Currently Being Moderated

TabbedViewNavigator, issue with removeAll

May 24, 2011 2:52 PM

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\TabbedViewNavigator.as:1239]
at spark.components::TabbedViewNavigator/addItemAt()[E:\dev\trunk\framew orks\projects\mobilecomponents\src\spark\components\TabbedViewNavigato r.as:1379]
at spark.components::TabbedViewNavigator/addItem()[E:\dev\trunk\framewor ks\projects\mobilecomponents\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). 

  • Currently Being Moderated
    May 25, 2011 7:23 PM

    Looks like a simple display list issue. I haven't gotten a chance to do much mobile dev with 4,5 yet so I'm not sure if this is the most elegant solution but adding this.tabbedNavigator.validateNow(); after your removeAll() solved the issue for me.

    |
    Mark as:
  • Currently Being Moderated
    Adobe Employee
    Jun 23, 2011 2:11 PM

    That would be great if you could please file a bug and post the link to it here.

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jul 1, 2011 6:16 AM

                    trace("app tabs");
                   
                    this.tabbedNavigator.removeAll();
                    this.tabbedNavigator.validateNow();
                   
                    var tab:ViewNavigator;
                    tab = new ViewNavigator;
                    tab.firstView = views.Cars;
                    tab.label = "Cars";
                    tab.percentHeight = 100;
                    tab.percentWidth = 100;
                    this.tabbedNavigator.addItem(tab);

     

    Still getting RangeError: Index '1' specified is out of bounds.
        at spark.components::TabbedViewNavigator/set selectedIndex(). Ill post on the bug forums but I wanted to see if anyone has a fix.

    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points