I commented my code below to reflect what I am attempting to do here. Flash is throwing me a 1084 error at the moment but I cannot spot my issue. I expect that it is something to do with the this['circle'+i] statement.
var boxOne = new box();
stage.addChild(boxOne);
boxOne.x = stage.stageWidth/2;
boxOne.y = stage.stageHeight/2; //This far is fine, no issues.
boxOne.addEventListener(MouseEvent.CLICK,spawn)
function spawn() { //Spawn function called by MouseEvent
for (var i:int = 0;i==5;i++) { //For a total of 5 times
var this['circle'+i] = new circle(); //Make a new circle object
stage.addChild(this['circle'+i]); //Add it to the stage
this['circle'+i].x = stage.stageWidth / (Math.random()*10); //Set X
this['circle'+i].y = stage.stageHeight / (Math.random()*10); //Set Y
}
}
Any input appreciated.