title: AS3: Generating multiple movie clips (random locations)?
body: <p>I'm trying to generate multiple stars in the stage, but I keep getting an action script error.</p>
  
  <pre><code>stop();
  var i;
  var arrayStars:Array;
  for(i=0; i&lt;70; i++) {
      arrayStars[i] = new Star(); //Star is a linked movie clip exported to AS3.
      arrayStars[i].x = Math.floor(Math.random() * 1650);
      arrayStars[i].y = Math.floor(Math.random() * 1060);
      addChild(arrayStars[i]);
  }
  </code></pre>
  
  <p>The error I get is: </p>
  
  <blockquote>
    <p><strong>TypeError: Error #1009:</strong> Cannot access a property or method of a null object reference.<br /><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at Untitled_fla::MainTimeline/frame1()[Untitled_fla.MainTimeline::frame1:7]<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at runtime::ContentPlayer/loadInitialContent()<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at runtime::ContentPlayer/playRawContent()<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at runtime::ContentPlayer/playContent()<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at runtime::AppRunner/run()<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at global/runtime::ADLEntry()</p>
  </blockquote>
  
  <p>Thanks in advance.</p>