PDA

View Full Version : HitTest between arrays?


Mya
10-28-2007, 08:20 PM
Hi guys,

I've been using the following code to execute functions whenever a 'ball' movieclip hits any element of a particular array - in this case, the 'dots' array:



var dots:Array = new Array();

var Index:Number

for(Index = 0; Index < dots.length; Index++){

if(ball.hitTest(dots[Index])){
trace("success!");
}//end if
}//end for


And this works fine...but what I'd like to do now is execute a function whenever an element from the 'dots' array hits an element from another array, named 'blips' for example -i've made a few attempts, but none have succeeded - could anyone suggest how I could do this?

Many thanks!!

Draxus
10-29-2007, 10:27 AM
for (i in dots)
{
for (i in otherArray)
{
if (dots[i].hitTest(otherArray[i]))
{
someFunction();
}
}
}