• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Event.ADDED_TO_STAGE is running twice...

Explorer ,
Mar 06, 2012 Mar 06, 2012

Copy link to clipboard

Copied



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






}
TOPICS
ActionScript

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 06, 2012 Mar 06, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 07, 2012 Mar 07, 2012

Copy link to clipboard

Copied

Also remove the Event.ADDED_TO_STAGE listener in startapp function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 07, 2012 Mar 07, 2012

Copy link to clipboard

Copied

LATEST

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

        }

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines