0 Replies Latest reply on Dec 1, 2006 4:44 PM by vitopn

    TabNavigator ALL tabs unselected

    vitopn
      I am having a problem with the tab navigator. When I clear it and repopulated it programmatically, it shows all of the tabs as unselected even though it is showing the contexts of the 1st tab.

      I've mocked up a sample that reproduces the issue (see below). Open the page and click the Rebuild button. Notice that both tabs are showing as unselected. Also note that clicking sel1st which sets the selectedIndex to 0 on the tab navigator has no effect. It is interesting to note that clicking selLast does work and once that is done sel1st also works.

      The problem appears to be caused by removing all of the children and the later (after the navigator has redrawn?) adding tabs.
      Has anyone seen this problem? Am I missing something?

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      import mx.containers.Canvas;

      private var num:int = 0;

      private function rebuildTN():void{
      tn.removeAllChildren();
      callLater(addChildren);
      }

      private function addChildren():void{
      var child:Canvas;
      for(var i:int = 0; i < 2; i++){
      child = new Canvas();
      child.label = num.toString();
      num++;
      tn.addChild(child);
      }
      }
      ]]>
      </mx:Script>
      <mx:TabNavigator id="tn" x="88" y="48" width="377" height="255">
      <mx:Canvas label="Tab 1" width="100%" height="100%">
      </mx:Canvas>
      </mx:TabNavigator>
      <mx:Button x="253" y="320" label="Rebuild" click="rebuildTN();"/>
      <mx:Button x="216" y="350" label="sel1st" click="tn.selectedIndex=0;"/>
      <mx:Button x="284" y="350" label="selLast" click="tn.selectedIndex=tn.numChildren-1"/>

      </mx:Application>