dimanche 19 février 2017

How Do You Add MovieClips to Stage From Classes?

Actionscript 3 classes are so confusing to me.

I have defined a variable up_dpad to dpad_up, where then I have attempted to add it to the stage by putting addChild(up_dpad) in the compiler function.

This is supposed to be simple code, but I cannot understand why it doesn't work, had it been on the timeline it would've worked just fine, and this is why I don't understand why people say to put code in classes rather than on the timeline, because from what I can tell it's so annoying. Sorry for the rant, I'm just frustrated.

Timeline

new Test();

Test.as Class

    package 
{
    import flash.display.MovieClip;

    public class Test extends MovieClip
    {
        var up_dpad:MovieClip = new dpad_Up();


        public function Test()
        {
            addChild(up_dpad);
        }

    }

}

Aucun commentaire:

Enregistrer un commentaire