lundi 22 février 2016

Error #1009- Only when there is code present in main class

Please do forgive me if this is a stupid question, by I really need to know the solution. So here I have a program that generates particles every set distance of space. My program consists of a document class, called supportForce and an object class(of the particle) called TheDot. In the TheDot object class, I have the following code-

    package 
    {

        import flash.display.MovieClip;
        import flash.events.Event;
        public class TheDot extends MovieClip
        {
            var base:Object = MovieClip(root);
            public function TheDot()
            {
                this.addEventListener(Event.ENTER_FRAME, eFrame);
            }
            private function eFrame(event:Event):void
            {
                if (base.currentFrame == 1){
                    trace ("G");
                }
            }
        }

    }

This code works perfectly (outputs G) until I add the following code into the document class, suportForce, under an ENTER_FRAME event-

var ctX:int = 0,ctY:int = 0,done:Boolean = false; 
while (done == false)
            {
                var dots:TheDot = new TheDot  ;
                dots.alpha = 0;
                dots.x +=  (25 * ctX);
                dots.y +=  (25 * ctY);
                ctX++;
                if (ctX == 22 && ctY == 20)
                {
                    done = true;
                    break;
                }
                else if (ctX == 22)
                {
                    ctX = 0;
                    ctY++;
                }
                stage.addChild(dots);
            }

So now, there is an Error #1009: Cannot access a property or method of a null object reference at TheDot/eFrame(). I have declared all the variables in the correct place, and also the functions. Thanks in advance. I have the link to the .fla and .as files in my drive here, do use it if necessary. http://ift.tt/1PU7Dle

Aucun commentaire:

Enregistrer un commentaire