Flex的TabNavigator中tab触发的事件
最近用到TabNavigator,想在那个tabBar上点选的时候触发一个自己的回调方法,可是想象中触发的事件和实际真正应该用到的那个是不一样的!
其实很容易的,就是说点击TabNavigator上的选项卡时触发的是IndexChangedEvent.CHANGE,而不是那个tabIndexChange。
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="InitApp()"> <mx:Script> <!--[CDATA[ import mx.events.IndexChangedEvent; private function InitApp():void { tabnavigator1.addEventListener(IndexChangedEvent.CHANGE,indexChangeHandler); } function indexChangeHandler(event:IndexChangedEvent):void { this.currentState='HideReminderEntry'; mybutton.label=tabnavigator1.getTabAt(tabnavigator1.selectedIndex ).label // if (event.triggerEvent is MouseEvent) // recordAutomatableEvent(event, false); // else // recordAutomatableEvent(event.triggerEvent, false); } ]]--> </mx:Script>