Pinball Wizard

Hey, i’m doing my best to make the step from AS2 to AS3 and thought a game would be the most bearable way to do it, at the very least i get to play games while i develop… but then i got stuck.

the problem i think is my limited understanding of scope:

I have a number of object in my stage, these are objects my pinball will bounce off,
i’m then running a for loop to capture there x,y positions and push them into an array.
Next i attachMovie, sorry addChild using the positions in that array

like so…

for (var i:int =0; i < objList.length; i++) {
var p:Point=new Point(objList*.x,objList*.y);
objList*.visible=false;
setObjs.push§;
var theSquare:square = new square();
theSquare.name=“theSquare”+i;
addChild(theSquare);
theSquare.x=setObjs*.x;
theSquare.y=setObjs*.y;
}

later on in my code i have one ENTER_FRAME that controls how my ball bounces and moves as it hits the edge of the stage (there are of course functions to handle this not shown here), it also detects when it hits little invisible shapes inside ‘theSquare’ named rightArea, leftArea, topArea, and bottomArea, in short this is what that code looks like.

addEventListener(Event.ENTER_FRAME, checkBallPos);

function checkBallPos(e:Event):void {

if (pinball.hitTestObject(theSquare.rightArea)) {
pinball.x=theSquare.x+theSquare.width/2+pinball.width/2;
objHit();
rightHit();
}

if (pinball.hitTestObject(theSquare.leftArea)) {
	pinball.x=theSquare.x-theSquare.width/2-pinball.width/2;
	objHit();
	leftHit();
}
if (pinball.hitTestObject(theSquare.bottomArea)) {
	pinball.y=theSquare.y+theSquare.height/2+pinball.height/2;
	objHit();
	bottomHit();
}

if (pinball.hitTestObject(theSquare.topArea)) {
	pinball.y=theSquare.y-theSquare.height/2-pinball.height/2;
	objHit();
	topHit();
}

}

problem is at this stage in the ‘theSquare’ is only one instance of the 7 objects added in my for loop.
and so the question

how, from inside this ENTER_FRAME do i reference or detect a hit on any one of the 7 objects attached in my for loop.

further more… if anyone has a better way to do collision detection that might solve this and make it better i’m all ears… but… my AS3 knowledge is still in it’s cave man stages … ug!

fla attached.

thanks in advance.