zoukankan      html  css  js  c++  java
  • Styling individual tabs in a TabBar control

    following example shows how you can style individual tabs in a Flex TabBar control by calling the getChildAt() method on the tab bar, and then calling setStyle() on the returned Tab reference.

    A big thanks to Joan for helping me figure it out

    <?xml version="1.0"?>
    <!-- http://blog.flexexamples.com/2007/11/19/styling-individual-tabs-in-a-tabbar-control/ -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            layout
    ="vertical"
            verticalAlign
    ="middle"
            backgroundColor
    ="white">

        
    <mx:Script>
        
    <![CDATA[
            import mx.events.ItemClickEvent;
            import mx.controls.tabBarClasses.Tab;

            private function tabBar_creationComplete():void {
                var colorArr:Array = ["red", "haloOrange", "yellow", "haloGreen", "haloBlue"];
                var color:String;
                var tab:Tab;
                var idx:uint;
                var len:uint = tabBar.dataProvider.length;

                for (idx = 0; idx < len; idx++) {
                    var i:int = idx % colorArr.length;
                    color = colorArr[i];
                    tab = Tab(tabBar.getChildAt(idx));
                    tab.setStyle("fillColors", [color, "white"]);
                    tab.setStyle("fillAlphas", [1.0, 1.0]);
                    tab.setStyle("backgroundColor", color);
                }
            }

            private function tabBar_itemClick(evt:ItemClickEvent):void {
                viewStack.selectedIndex = evt.index;
            }
        
    ]]>
        
    </mx:Script>

        
    <mx:Array id="arr">
            
    <mx:Object label="Red" />
            
    <mx:Object label="Orange" />
            
    <mx:Object label="Yellow" />
            
    <mx:Object label="Green" />
            
    <mx:Object label="Blue" />
        
    </mx:Array>

        
    <mx:TabBar id="tabBar"
                dataProvider
    ="{arr}"
                creationComplete
    ="tabBar_creationComplete();"
                itemClick
    ="tabBar_itemClick(event);" />

        
    <mx:ViewStack id="viewStack"
                width
    ="{tabBar.width}"
                styleName
    ="plain">
            
    <mx:VBox id="redVBox" width="100%" height="100">
                
    <mx:Label text="Red VBox" />
            
    </mx:VBox>
            
    <mx:VBox id="orangeVBox" width="100%" height="100">
                
    <mx:Label text="Orange VBox" />
            
    </mx:VBox>
            
    <mx:VBox id="yellowVBox" width="100%" height="100">
                
    <mx:Label text="Yellow VBox" />
            
    </mx:VBox>
            
    <mx:VBox id="greenVBox" width="100%" height="100">
                
    <mx:Label text="Green VBox" />
            
    </mx:VBox>
            
    <mx:VBox id="blueVBox" width="100%" height="100">
                
    <mx:Label text="Blue VBox" />
            
    </mx:VBox>
        
    </mx:ViewStack>

    </mx:Application>

  • 相关阅读:
    改进初学者的PID-微分冲击
    孤独
    改进初学者的PID-采样时间
    mac10.9下eclipse的storm开发环境搭建
    ubuntu12.04+hadoop2.2.0+zookeeper3.4.5+hbase0.96.2+hive0.13.1伪分布式环境部署
    Linux学习笔记之rpm包管理功能全解
    Linux学习笔记之文件读取过程
    Linux学习笔记之Linux系统的swap分区
    Linux学习笔记之grep命令和使用正则表达式
    Prometheus监控学习笔记之容器监控Grafana模块
  • 原文地址:https://www.cnblogs.com/taobataoma/p/1037060.html
Copyright © 2011-2022 走看看