简体   繁体   English

更改Flex 3中的标签样式

[英]Change style of tabs in Flex 3

I am new to Flex 3.4. 我是Flex 3.4的新手。 I want to change style of few tabs (highlight them) on click of a button. 我想在单击按钮时更改几个标签的样式(突出显示)。 I came from a javascript background and not able interpret in Flex's way. 我来自javascript背景,无法以Flex的方式进行解释。

Styling tabs in Flex is sort of tricky - the TabBar and TabNavigator classes have a style called tabStyleName , which is the name of another separate style that defines the look of your tabs. Flex中标签的样式有点棘手tabStyleName和TabNavigator类具有一种名为tabStyleName的样式,这是定义标签外观的另一种单独样式的名称。 Here's an example which changes a set of tabs from a red background to blue by changing the tabStyleName style on the TabBar - hopefully you can adapt it to whatever you need. 这是一个示例,该示例通过更改TabBar上的tabStyleName样式将一组选项卡从红色背景更改为蓝色-希望您可以根据需要进行调整。


  <mx:Style>
    .redTabs {
      fillColors: #cc0000, #cc0000;
    }

    .blueTabs {
      fillColors: #0000cc, #0000cc;
    }
  </mx:Style>

  <mx:Script>
    <![CDATA[
      protected function changeStyle(event:MouseEvent):void
      {
        theTabs.setStyle("tabStyleName", "blueTabs");
      }
    ]]>
  </mx:Script>

  <mx:TabNavigator id="theTabs" x="10" y="10" width="200" height="200" tabStyleName="redTabs">
    <mx:Canvas label="apple" width="100%" height="100%">
    </mx:Canvas>
    <mx:Canvas label="orange" width="100%" height="100%">
    </mx:Canvas>
    <mx:Canvas label="banana" width="100%" height="100%">
    </mx:Canvas>
  </mx:TabNavigator>

  <mx:Button x="10" y="218" label="Change Style!" click="changeStyle(event)"/>

Edit: I've changed the example to work with TabNavigator. 编辑:我已更改示例以与TabNavigator一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM