views:

1759

answers:

2

Hi, I am a flex newbie. I need to disable some of the tabs in a flex tabbar specified, by configuration. I am having trouble in iterating over the tabs in the tab bar. If i use getChildAt() command, it does not disable the tab button, but the content of that tab button, so its no good.

Thanks and regards, Mohit Ranka

A: 

why not use a bindable to your configuration?

something like

   enabled="{yourConfiguration.lastResult.enabled}"
Peter Miehle
because the requirement is more complex than this. bottleneck is i do not know how to iterate over tabs in tab bar.
Mohit Ranka
+2  A: 

When asking about code, always post a minimal test case. getChildAt() will work, so there's something else going on with your code.

<mx:Script>
    <![CDATA[
        import mx.events.ItemClickEvent;
        import mx.controls.tabBarClasses.Tab;
        private function clickTab(event:ItemClickEvent):void {
            var target:TabBar = event.currentTarget as TabBar;
            var currTab:Tab;
            var parity:int = event.index & 1;
            /* disable all tabs at indices w/ same parity as clicked tab;
               enable tabs of opposite parity.
             */
            for (var i=0; i<target.numChildren; ++i) {
               currTab = target.getChildAt(i) as Tab;
               currTab.enabled = (i&1)^parity;
            }
        }
    ]]>
</mx:Script>

<mx:TabBar id="someTabs" itemClick="clickTab(event)">
    <mx:dataProvider>
     <mx:String>Foo</mx:String>
     <mx:String>Bar</mx:String>
     <mx:String>Baz</mx:String>
     <mx:String>Bam</mx:String>
    </mx:dataProvider>
</mx:TabBar>
outis