http://yansy115.blog.163.com/blog/static/23308504200941942656770/
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
verticalAlign="top"
backgroundColor="white" themeColor="#FFFFFF" width="310" height="122" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]">
<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);
}*/
<!-- 我自已修改的-->
color = colorArr[0];
tab = Tab(tabBar.getChildAt(0));
// tab.setStyle("fillColors", [color, "white"]);
// tab.setStyle("fillAlphas", [1.0, 1.0]);
// tab.setStyle("backgroundColor", color);
tab.setStyle("paddingLeft",15);
tab.setStyle("paddingRight",15);
tab = Tab(tabBar.getChildAt(1));
tab.width=100;
tab = Tab(tabBar.getChildAt(2));
tab.setVisible(false);
tab = Tab(tabBar.getChildAt(3));
tab.setVisible(false);
}
private function tabBar_itemClick(evt:ItemClickEvent):void {
viewStack.selectedIndex = evt.index;
}
]]>
</mx:Script>
<mx:Array id="arr">
<mx:Object label="Red Red" />
<mx:Object label="Orange" />
<mx:Object label="Yellow" />
<mx:Object label="Green" />
</mx:Array>
<mx:TabBar id="tabBar"
dataProvider="{arr}"
creationComplete="tabBar_creationComplete();"
itemClick="tabBar_itemClick(event);" x="0" y="0" />
<mx:ViewStack id="viewStack"
width="{tabBar.width}"
x="0" y="21" >
<mx:VBox id="redVBox" width="100%" height="100" verticalAlign="top" verticalGap="0" horizontalAlign="left" borderStyle="solid" autoLayout="false">
<mx:Label text="Red 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:ViewStack>
</mx:Application>