3 Replies Latest reply on Jul 6, 2011 10:29 AM by JennHysuick

    Tab Navigator Question

    JennHysuick

      I have created a <mx:TabNavigator> with a few <s:NavigaortContent> children.  On creationComplete of the applicaiton, I set the selectedIndex of the navigator, depending on the currentState.

       

      When I run the applicaiton, I see the correct content for the set selectedIndex, but the tabs at the top show that tab 0 is selected (so the visually selected tab does not match the content of the selectedIndex).

       

      Am I missing something?  I don't recall this being all that difficult of a thing to do.

       

      Thanks!

       

      Jenn

        • 1. Re: Tab Navigator Question
          Kumar Pratik Level 1

          Can u post your code for better understanding..

          • 2. Re: Tab Navigator Question
            Gregory Lafrance Level 6

            Make sure you set the "label" property of the NavigatorContent instances, as that is what actually gets displayed in the tabs, not the "id" or "name" property.

             

            If this post answers your question, or helps answer your question, please mark it as such.

            • 3. Re: Tab Navigator Question
              JennHysuick Level 1

              OK - I have each navigator content labelled... Here is the code I'm using if that helps out...

               

              <mx:TabNavigator width="90%" height="90%" horizontalCenter="0" verticalCenter="0" id="navTabs" fontFamily="Arial" fontSize="12" change="tabChanged()">
                      <s:NavigatorContent id="tnHome" label="Home" width="100%" height="100%" includeIn="administrator,default,student" >

                             <!-- my content is here -->

                      </s:NavigatorContent>
                      <s:NavigatorContent includeIn="default, student,administrator" label="About" width="100%" height="100%" id="tnAbout">
                              <!-- my content is here -->
                      </s:NavigatorContent>

              </mx:TabNavigator>

               

              private function initApp():void

              {

                   if ( user.role == "student" ) {
                        currentState = "student";
                        navTabs.selectedIndex = 0;
                        Alert.show("you are a student");
                  }

                 else if ( user.role == "admin" ) {
                       currentState = "administrator";
                       navTabs.selectedIndex = 1;
                   }

              }

               

              protected function tabChanged():void
                          {
                              switch(navTabs.selectedIndex) {
                                  case 0 : //home
                                      break;
                                  case 1:
                                      break;
                                  case 2: //Courses
                                      courses.getAllList();
                                      break;
                                  case 3: //My Training
                                      //from here, we want to get get any/all registrations and history
                                      break;
                                  case 4: //Resource
                                      courses.getAllResources();
                                      break;
                                  case 5: // Administration
                                      break;
                                 
                              }
                          }

               

              So, when I enter in with the role of admin, I see the content of the About tab, but the 'selected tab' at the top is still the Home tab.   Hope that clears up my problem.

               

              Thanks!