在flex中选择选项卡式面板

时间:2012-03-06 09:49:26

标签: flex flex4

我在flex中有一个标签面板,有各种标签,我使用它来获取所选的标签索引

private function handleInspectorAreaButtonClick(e:Event):void
        {
            var selectedIndex:int;

            switch(Button(e.target))
            {
                case propertiesButton:
                    selectedIndex = 0;
                    break;

                case dimensionsButton:
                    selectedIndex = 1;
                    break;

                case footnotesButton:
                    selectedIndex = 2;
                    break;

                case calculationsButton:
                    selectedIndex = 3;
                    break;

                case whereUsedButton:
                    selectedIndex = 4;
                    break;
            }

            inspectorAreaViewStack.selectedIndex = selectedIndex;
        }

但问题是我没有让选定的选项卡索引值m变为NULL,因此未选中该选项卡这是m选择的面板

    <s:HGroup id="inspectorAreaViewStackControls" width="100%" paddingTop="8" paddingLeft="4" paddingRight="4">
        <s:Button id="property" label="Properties" click="handleInspectorAreaButtonClick(event)"/>
        <s:Button id="distance" label="Dimensions" click="handleInspectorAreaButtonClick(event)"/>

    </s:HGroup>

这是我想要更改的视图堆栈

<mx:ViewStack id="inspectorAreaViewStack" width="100%" height="100%" paddingTop="8" paddingLeft="4" paddingRight="4" selectedIndex="0" backgroundColor="0xFFFFFF">

            <s:NavigatorContent width="100%" label="propertiesContent">
                <tagInspectorAspects:PropertiesAspect id="propertiesAspect"/>
            </s:NavigatorContent>

            <s:NavigatorContent width="100%" label="dimensionsContent">
                <tagInspectorAspects:DimensionsAspect/>
                    </mx:ViewStack>

2 个答案:

答案 0 :(得分:0)

<s:HGroup id="inspectorAreaViewStackControls" width="100%" paddingTop="8" paddingLeft="4" paddingRight="4">
        <s:Button id="property" label="Properties" click="handleInspectorAreaButtonClick(event)"/>
        <s:Button id="distance" label="Dim" click="handleInspectorAreaButtonClick(event)"/>
</s:HGroup>


private function handleInspectorAreaButtonClick(e:Event):void
        {
            var selectedIndex:int;

            switch(e.currentTarget.id)
            {
                case 'property':
                    selectedIndex = 0;
                    break;

                case 'distance':
                    selectedIndex = 1;
                    break;
            }

            inspectorAreaViewStack.selectedIndex = selectedIndex;
        }

答案 1 :(得分:0)

您可以使用以下特定声明

{     event.currentTarget.selectedIndex;

} 事件必须是鼠标事件。

相关问题