max1x106
02-24-2007, 03:49 PM
I have 10 instances of a mc (Ball_mc1, Ball_mc2, ...) created at runtime. I have attached a reference to each instance in a unique array element: ball_array[1, 2, ...]. In a loop I have code to make the balls wander around triggered by an onEnterFrame event. I also have code which I hoped would detect collisions between the balls but it does not. Below is the code I have and line eight is where I think I am doing something wrong.
1 ball_array = new Array(11)
2 this.createEmptyMovieClip("holderClip", this.getNextHighestDepth());
3 for (var i:Number = 1; i <= 10; i++){
4 ball_array[i]=holderClip.attachMovie("Ball_mc", "Ball_mc" + i, holderClip.getNextHighestDepth(),
{_x:random(550), _y:random(400)});
5 ball_array[i].onEnterFrame=function(){
6 Wander around code
7 for (j = 1; j <= 10; j++){
8 if (ball_array[i].hitTest(ball_array[j])){setProperty (ball_array[j], _alpha, 20);}
9 }//eo sec loop over j
10 }//eo enter frame event
11 }//eo primary loop over i
1 ball_array = new Array(11)
2 this.createEmptyMovieClip("holderClip", this.getNextHighestDepth());
3 for (var i:Number = 1; i <= 10; i++){
4 ball_array[i]=holderClip.attachMovie("Ball_mc", "Ball_mc" + i, holderClip.getNextHighestDepth(),
{_x:random(550), _y:random(400)});
5 ball_array[i].onEnterFrame=function(){
6 Wander around code
7 for (j = 1; j <= 10; j++){
8 if (ball_array[i].hitTest(ball_array[j])){setProperty (ball_array[j], _alpha, 20);}
9 }//eo sec loop over j
10 }//eo enter frame event
11 }//eo primary loop over i