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 <nahloulaha...@...> 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
>


Reply via email to