<? xml version="1.0" encoding="utf-8" ?> < mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml" layout ="absolute" > < mx:Script > <![CDATA[ import mx.events.ItemClickEvent; internal function btn_click_handler(evt:ItemClickEvent):void{ viewstack1.selectedIndex=evt.index;//将viewStack和TabBar的状态保持同一个位置 } ]]> </ mx:Script > < mx:Panel x ="28" y ="21" width ="329" height ="253" layout ="absolute" title ="TabBar实例" id ="tab1" > < mx:TabBar x ="10" y ="10" 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 ="26" id ="viewstack1" width ="200" height ="200" > < mx:Canvas id ="child1" label ="View 1" width ="100%" height ="194" > < mx:List height ="184" > < mx:Array > < mx:Object label ="选择你感兴趣的技术" ></ mx:Object > < mx:Object label ="Flash" ></ mx:Object > < mx:Object label ="Flex" ></ mx:Object > < mx:Object label ="java" ></ mx:Object > < mx:Object label ="j2ee" ></ mx:Object > </ mx:Array > </ mx:List > </ mx:Canvas > < mx:Canvas id ="child2" > < mx:TextInput text ="请输入你的邮箱地址" ></ mx:TextInput > </ mx:Canvas > < mx:Canvas id ="child3" > < mx:Button label ="这是一个button" ></ mx:Button > </ mx:Canvas > < mx:Canvas id ="child4" > < mx:Button label ="这又是一个button" ></ mx:Button > </ mx:Canvas > </ mx:ViewStack > </ mx:Panel > </ mx:Application >