The oldIndex is the tab that was current before you click on another tab.  So 
if you have two tabs (like in the demo) with the indices of 0 and 1 and you 
click on the second tab, the oldIndex will be zero (0) and the new tab will be 
one (1).  If you then click on tab 1, oldIndex will be 1 and newIndex will be 0.

The demo app. posted outputs that information in the trace window.



--- In flexcoders@yahoogroups.com, Nini7016 Nini7016 <nahloulaha...@...> wrote:
>
> 
> it is me again :)
> I don't understand evt.oldIndex 
> how we can identify which child is cliked ???
> 
> Because depending the tab clicked i will do action  :(
> 
> Thank you very much :) :)
> it is very helpful 
> 
> To: flexcoders@yahoogroups.com
> From: james.alan.finni...@...
> Date: Wed, 17 Mar 2010 16:55:14 +0000
> Subject: [flexcoders] Re: How to identify which child of tabNavigatoris 
> clicked?
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  
> 
> 
> 
>   
> 
> 
>     
>       
>       
>       
> 
> 
> 
> Here's a complete working example to start with...
> 
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
> applicationComplete="TabOnglet()">
> 
>       
> 
>       <mx:Script>
> 
>               <![CDATA[
> 
>                       import mx.events.IndexChangedEvent;
> 
>                       import mx.containers.TabNavigator;
> 
>                       import mx.containers.Canvas;
> 
>                       import mx.controls.Button;
> 
>                       
> 
>               public function TabOnglet():void
> 
>         {
> 
>             this.setStyle("borderStyle" , "solid");
> 
>             //this.percentHeight = 100;
> 
>             this.percentWidth = 100;
> 
>             this.createTab(new TabNavigator());
> 
>             //create an listen to the event
> 
>             this.initEventListener();
> 
> 
> 
> }
> 
>         /**
> 
>          *
> 
>          * @param tabNavigator
> 
>          *
> 
>          */     
> 
>          
> 
>         private var _myTab:TabNavigator;
> 
>             
> 
>         private function createTab(tabNavigator:TabNavigator) : void
> 
>         {
> 
>               _myTab = tabNavigator;
> 
>               _myTab.percentHeight = 100;
> 
>               _myTab.percentWidth = 100;
> 
>               
> 
>             var canvas1: Canvas= new Canvas();
> 
>             canvas1.percentHeight=100;
> 
>             canvas1.percentHeight = 100;
> 
>             canvas1.percentWidth = 100;
> 
>             canvas1.label = "BPMN";
> 
> 
> 
> var canvas2: Canvas= new Canvas();
> 
>             canvas2.percentHeight=100;
> 
>             canvas2.percentHeight = 100;
> 
>             canvas2.percentWidth = 100;
> 
>             canvas2.label = "BPEL";
> 
>             canvas2.id="bpel";
> 
> 
> 
> tabNavigator.addChild(canvas2);
> 
>             tabNavigator.addChild(canvas1);
> 
>             
> 
>             this.addChild(tabNavigator);
> 
> 
> 
>                       tabNavigator.addEventListener(Event.CHANGE, changed);
> 
>         }
> 
> 
> 
>               private function changed(evt:IndexChangedEvent):void{
> 
>                       
> 
>                       trace("Tab changed from (" + evt.oldIndex + ") to (" + 
> evt.newIndex + ")");
> 
>               }
> 
> 
> 
> /**
> 
>          * initialise the event
> 
>          *
> 
>          */       
> 
>         private function initEventListener() : void
> 
>         {
> 
> 
> 
> trace(this + " cré un écouteur");
> 
>            
> 
> //            trace(_myTab.getTabAt(1) + 
> "------------------------this.getTabAt(1)______________r");
> 
>             //this.addEventListener(MouseEvent.CLICK, interceptClick, true);
> 
> //            var tab:Button = _myTab.getTabAt(1);
> 
> //            tab.addEventListener(MouseEvent.CLICK,interceptClick); 
> 
>             //this.getChildAt(1).addEventListener(MouseEvent.CLICK, 
> interceptClick, true);
> 
>           
> 
>         }
> 
> 
> 
>                       
> 
>               ]]>
> 
>       </mx:Script>
> 
>       
> 
> </mx:Application>
> 
> 
> 
> --- In flexcoders@yahoogroups.com, Nini7016 Nini7016 <nahloulahanem@> wrote:
> 
> >
> 
> > 
> 
> > Hello 
> 
> > 
> 
> > 
> 
> > I would like to know which child of tabNavigator is clicked :
> 
> > 
> 
> > There is my code : 
> 
> > 
> 
> > public function TabOnglet()
> 
> >         {
> 
> >             super();
> 
> >             this.setStyle("borderStyle" , "solid");
> 
> >             //this.percentHeight = 100;
> 
> >             this.percentWidth = 100;
> 
> >             this.createTab(this);
> 
> >             //create an listen to the event
> 
> >             this.initEventListener();
> 
> > 
> 
> >         }
> 
> >         /**
> 
> >          *
> 
> >          * @param tabNavigator
> 
> >          *
> 
> >          */          
> 
> >         private function createTab(tabNavigator : TabNavigator) : void
> 
> >         {
> 
> >             var canvas1: Canvas= new Canvas();
> 
> >             canvas1.percentHeight=100;
> 
> >             canvas1.percentHeight = 100;
> 
> >             canvas1.percentWidth = 100;
> 
> >             canvas1.label = "BPMN";
> 
> > 
> 
> >             var canvas2: Canvas= new Canvas();
> 
> >             canvas2.percentHeight=100;
> 
> >             canvas2.percentHeight = 100;
> 
> >             canvas2.percentWidth = 100;
> 
> >             canvas2.label = "BPEL";
> 
> >             canvas2.id="bpel";
> 
> > 
> 
> >             tabNavigator.addChild(canvas2);
> 
> >             tabNavigator.addChild(canvas1);
> 
> >         }
> 
> >         /**
> 
> >          * initialise the event
> 
> >          *
> 
> >          */        
> 
> >         private function initEventListener() : void
> 
> >         {
> 
> > 
> 
> >             trace(this + " cré un écouteur");
> 
> >             
> 
> >             trace(this.getTabAt(1) + 
> > "------------------------this.getTabAt(1)______________r");
> 
> >             //this.addEventListener(MouseEvent.CLICK, interceptClick, true);
> 
> >             var tab:Button = this.getTabAt(1);
> 
> >             tab.addEventListener(MouseEvent.CLICK,interceptClick);  
> 
> >             //this.getChildAt(1).addEventListener(MouseEvent.CLICK, 
> > interceptClick, true);
> 
> >            
> 
> >         }
> 
> > 
> 
> > in the browser it displays this message : 'Il est impossible d'accéder à la 
> > propriété ou à la méthode d'une référence d'objet nul" that is mean it is 
> > impossible to acceed to a propriety or method of a reference of object  
> > which is nul .
> 
> > 
> 
> > 
> 
> > Thanks 
> 
> > 
> 
> > Any idea please ???
> 
> > 
> 
> >  
> 
> >                                       
> 
> > __________________________________________________________
> 
> > Hotmail arrive sur votre téléphone ! Compatible Iphone, Windows Phone, 
> > Blackberry, …
> 
> > http://www.messengersurvotremobile.com/?d=Hotmail
> 
> >
> 
> 
> 
> 
> 
> 
>     
>      
> 
>     
>     
> 
> 
> 
> 
> 
> 
>                                         
> _________________________________________________________________
> Consultez gratuitement vos emails Orange, Gmail, Free, ... directement dans 
> HOTMAIL !
> http://www.windowslive.fr/hotmail/agregation/
>


Reply via email to