4,328
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="utf-8"?>
<mx:TabNavigator xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" creationComplete="init()">
<mx:Script>
<![CDATA[
private function init():void
{
this.tabBar.addEventListener(MouseEvent.MOUSE_OVER, handleOver);
}
private function handleOver(evt:MouseEvent):void
{
var childName:String = evt.target.name;
var dobj:* = this.tabBar.getChildByName(childName)
this.selectedIndex = this.tabBar.getChildIndex(dobj);
}
]]>
</mx:Script>
</mx:TabNavigator>
<?xml version="1.0" encoding="utf-8"?>
<mx:TabNavigator xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" creationComplete="init()">
<mx:Script>
<![CDATA[
private function init():void
{
this.tabBar.addEventListener(MouseEvent.MOUSE_OVER, handleOver);
}
private function handleOver(evt:MouseEvent):void
{
switch(evt.target.label) {
case "Page1" :
this.selectedIndex = 0;
break;
case "Page2" :
this.selectedIndex = 1;
break;
case "Page3" :
this.selectedIndex = 2;
break;
}
}
]]>
</mx:Script>
</mx:TabNavigator>
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" xmlns:ns1="*">
<ns1:MyTabNavigator id="myTab" width="100%" height="100%" >
<mx:Canvas label="Page1" width="100%" height="100%">
<mx:Text text="第一个页面" width="100%" fontSize="21"/>
</mx:Canvas>
<mx:Canvas label="Page2" width="100%" height="100%">
<mx:Text text="第二个页面" width="100%" fontSize="21"/>
</mx:Canvas>
<mx:Canvas label="Page3" width="100%" height="100%">
<mx:Text text="第三个页面" width="100%" fontSize="21"/>
</mx:Canvas>
</ns1:MyTabNavigator>
</mx:WindowedApplication>