Skip navigation
Currently Being Moderated

Event.ADDED_TO_STAGE is running twice...

Mar 6, 2012 11:06 PM

Tags: #is #running #event.added_to_stage #twice...


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






}
 
Replies
  • Currently Being Moderated
    Mar 6, 2012 11:39 PM   in reply to Amit Shakya

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 7, 2012 1:37 AM   in reply to Amit Shakya

    Also remove the Event.ADDED_TO_STAGE listener in startapp function.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 7, 2012 1:39 AM   in reply to Amit Shakya

    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

            }

     

        }

     

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points