What if (stage) init(); means in actionscript ?

Posted by asksuperuser on Stack Overflow See other posts from Stack Overflow or by asksuperuser
Published on 2010-06-06T21:12:54Z Indexed on 2010/06/06 21:22 UTC
Read the original article Hit count: 104

Filed under:

I'm creating my first as3 with flashdevelop I don't understand what the instructions mean:

package 
{
    import flash.display.Sprite;
    import flash.events.Event;

    public class Main extends Sprite 
    {

        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
        }

    }

}

What if (stage) init(); means ? What is Event.ADDED_TO_STAGE ? Why remove listener in init ?

© Stack Overflow or respective owner

Related posts about flash