Code in frame 1 layer 1:




//lotsOfSprites.fla

//Demonstrates creating multiple sprites at run time





i = 0;



theButton.onRelease = function(){

  i++;

  _root.attachMovie("ball", "ball_" + i, 10 + i);

  currentBall = eval("ball_" + i);

  currentBall._x = Math.random() * Stage.width;

  currentBall._y = Math.random() * Stage.height;

  currentBall.index = i;

  trace ("the index is " + currentBall.index);



  currentBall.onRelease = function(){

    output = "last ball clicked...  #" + this.index;

    this.removeMovieClip();

  } // end onRelease

        

} // end theButton