3 Replies Latest reply on Jul 19, 2010 1:16 PM by josyeh2

    Completely hiding tab and content in TabNavigator

    josyeh2 Level 1

      Hi All,

       

      Does anyone know how to hide a tab in TabNavigator?  I want the tab in the tab bar to dissappear so that you cannot see, click, nor view the tab or associated page.

       

      I have tried visibility="false", getting rid of the dataProvider cell that corresponds with the tab (this only affects data obviously and not the view), and extending the tabNavigator component (but not successful).

       

      My setup is:

       

          <vo:TabNavigator id="mainTabNavigator4Components" selectedIndex="{model.selectedComponentIndex}">

              <mx:Repeater id="rp" dataProvider="{model.components}">

                  <mx:Canvas label="{rp.currentItem.team}">

       

       

      Thanks for any input everyone.

       

      Regards,

      Joseph

        • 1. Re: Completely hiding tab and content in TabNavigator
          rtalton Level 4

          The basic idea is to loop through the Tab Navigator's children, use the getTabAt() method to return the Tab as a button, then show/hide the button using the visible property:

           

                  private function disableSomeTabs():void{
                      //Called by a tab navigator's creation complete event.
                  // This Tab Navigator's id is "Mytn".
                      //Hide a Tab with a certain name ('My Hidden Tab').
                      var i:int;
                      for (i = 0; i < Mytn.numChildren; i++){
                          var dispObj:Button =  Mytn.getTabAt(i);
                          if (dispObj.label == 'My Hidden Tab'){
                              dispObj.visible = false;
                          }
                      }        
                  }

          • 2. Re: Completely hiding tab and content in TabNavigator
            josyeh2 Level 1

            Thanks for the input.  My tabNavigator returns 0 for both numChildren and numElements.  Doesn't make any sense.

            • 3. Re: Completely hiding tab and content in TabNavigator
              josyeh2 Level 1

              I forgot to mention, I am using a repeater in my TabNavigator to produce a dynamic number of tabs based on a dataProvider.  That may      be why my TabNavigator has no children nor elements.  I

               

                  <mx:TabNavigator id="mainTabNavigator4Components"
                                   backgroundColor="#666666"
                                   selectedIndex="{model.selectedComponentIndex}"

                                  creationComplete="hideTabs()"
                                   >
                      <mx:Repeater id="rp" dataProvider="{model.components}">