Error #1009- Only when there is code present in main class
<p>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-</p>

<pre><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");
                }
            }
        }

    }
</code></pre>

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

<pre><code>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 &amp;&amp; ctY == 20)
                {
                    done = true;
                    break;
                }
                else if (ctX == 22)
                {
                    ctX = 0;
                    ctY++;
                }
                stage.addChild(dots);
            }
</code></pre>

<p>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.
<a href="https://drive.google.com/folderview?id=0B8QnUfRAn9lKLUVqRjNSRHNpRkU&amp;usp=sharing" rel="nofollow">https://drive.google.com/folderview?id=0B8QnUfRAn9lKLUVqRjNSRHNpRkU&amp;usp=sharing</a></p>