문제

나는 플렉스 초보자이다. 구성별로 지정된 Flex Tabbar에서 일부 탭을 비활성화해야합니다. 탭 막대의 탭을 반복하는 데 어려움이 있습니다. getChildat () 명령을 사용하면 탭 버튼이 비활성화되지 않지만 해당 탭 버튼의 내용이 좋지 않으므로 좋지 않습니다.

감사합니다

도움이 되었습니까?

해결책

코드에 대해 질문 할 때 항상 최소 테스트 사례를 게시하십시오. getChildAt() 작동하므로 코드에 다른 일이 진행되고 있습니다.

<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>

다른 팁

구성에 바인딩 가능한 것을 사용하지 않는 이유는 무엇입니까?

같은 것

   enabled="{yourConfiguration.lastResult.enabled}"

Flex 4.5에 대한 답변을 원하는 사람들 (아마도 Flex 4도). 나는 마침내 해결책을 알아 냈다. 그것은 나에게 해킹처럼 느껴지지만 Adobe는 전화에 응답하지 않고 저를 위해 일하고 있습니다. 여기 단순화 된 예입니다.

<!-- component that has the the TabBar in it... -->

<fx:Script>
    <![CDATA[
//imports here

import mx.core.UIComponent;

//imports

private function setTabEnabled(index:int,enabled:Boolean):void{
    var theTab:UIComponent = theTabBar.dataGroup.getElementAt(index) as UIComponent;
    if(theTab){theTab.enabled = enabled;}
}
]]>
</fx:Script>

<s:TabBar id="theTabBar"
    dataProvider="{viewStack}"/>

<mx:ViewStack id="viewStack">
    <s:NavigatorContent label="0th Tab">
        <!-- ...Content -->
    </s:NavigatorContent>
    <s:NavigatorContent label="1st Tab">
        <!-- ...Content -->
    </s:NavigatorContent>
    <s:NavigatorContent label="2nd Tab">
        <!-- ...Content -->
    </s:NavigatorContent>
</mx:ViewStack>

<!-- rest of the component that has the the TabBar in it... -->

그럼 당신은 그냥 전화합니다 setTabEnabled(theTabIndex,trueFalse) 탭이 사용되는 이유를 결정하는 모든 것과 관련된 이벤트 핸들러에서.

~해야 한다 이것을 지원하기 위해 탭 바를 확장했지만 이미 그것을 알아 내려고 충분한 시간을 보냈습니다.

행복한 코딩 = d

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top