tabBar.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--http://www.javaeye.com/topic/210348-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Style source="style.css"/>
<mx:Script>
<![CDATA[
import mx.events.ItemClickEvent;
internal function btn_click_handler(evt:ItemClickEvent):void{
myViewstack.selectedIndex = evt.index;
}
]]>
</mx:Script>
<mx:Panel x="43" y="10" width="366" height="310" layout="absolute" horizontalGap="0" verticalGap="0" title="TabBar实例" borderStyle="solid">
<mx:TabBar id="btns" x="10" y="10" width="308" itemClick="btn_click_handler(event)">
<mx:dataProvider>
<mx:Array>
<mx:String>Flex</mx:String>
<mx:String>Flash</mx:String>
<mx:String>FMS</mx:String>
<mx:String>FDS</mx:String>
</mx:Array>
</mx:dataProvider>
</mx:TabBar>
<mx:ViewStack x="10" y="40" id="myViewstack" width="308" height="200">
<mx:Canvas id="child1" label="View 1" width="100%" height="100%">
<mx:List>
<mx:Array>
<mx:Object label="请选择您感兴趣的技术:"/>
<mx:Object label="Flash"/>
<mx:Object label="Flex"/>
<mx:Object label="Flash Media server"/>
<mx:Object label="Breeze"/>
</mx:Array>
</mx:List>
</mx:Canvas>
<mx:Canvas id="child2" label="View 2" width="100%" height="100%">
<mx:TextInput text="请输入您的邮箱地址" />
<mx:Button x="168" y="1" label="订阅Flash Rss"/>
</mx:Canvas>
<mx:Canvas id="child3" label="View 3" width="100%" height="100%">
<mx:Label text="FMS 2.0.4发布了" />
</mx:Canvas>
<mx:Canvas id="child4" label="View 4" width="100%" height="100%">
<mx:Label text="Breeze" />
</mx:Canvas>
</mx:ViewStack>
</mx:Panel>
</mx:Application>