Skip to main content
Inspiring
March 7, 2012
Question

Event.ADDED_TO_STAGE is running twice...

  • March 7, 2012
  • 3 replies
  • 1600 views


public function main() {<<<< CLASS CONSTRUCTOR



this.addEventListener(Event.ADDED_TO_STAGE,startapp)


}






private function startapp(event:Event):void{



trace('start app') <<TRACING TWICE..



//instructionscreen()



closebtn.visible=false



closebtn.alpha=0



controls.alpha=0






}
This topic has been closed for replies.

3 replies

Inspiring
March 7, 2012

You can do something like this :

package

{

    import flash.events.Event;

    import flash.display.*

    public class Testing extends MovieClip

    {

        public function Testing()

        {

           if (stage) startapp();

          else addEventListener(Event.ADDED_TO_STAGE,startapp);

        }  

        private function startapp(event:Event = null):void

        {

            removeEventListener(Event.ADDED_TO_STAGE,startapp);

            trace('start app')

            //instructionscreen()

            closebtn.visible=false

            closebtn.alpha=0  

            //controls.alpha=0

        }

    }

}

Inspiring
March 7, 2012

Also remove the Event.ADDED_TO_STAGE listener in startapp function.

March 7, 2012

package

{

    import flash.events.*;

    import flash.display.*

    public class Testing extends MovieClip

    {

        public function Testing()

        {

            addEventListener(Event.ADDED_TO_STAGE,startapp)

   

        }   

       

        private function startapp(event:Event):void

        {

            trace('start app')

            //instructionscreen()

            closebtn.visible=false

            closebtn.alpha=0   

            //controls.alpha=0

        }

       

    }

   

}

its running for once only