# Array hitTest Difficulties

**URL:** https://forum.kirupa.com/t/array-hittest-difficulties/143927
**Category:** Uncategorized
**Created:** [April 10, 2005, 3:48am UTC](https://forum.kirupa.com/t/array-hittest-difficulties/143927 "2005-04-10T03:48:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Kaiser\_SozE1](https://avatars.discourse-cdn.com/v4/letter/k/898d66/32.png) [@Kaiser\_SozE1](https://forum.kirupa.com/u/Kaiser_SozE1)
#### Post date: [April 10, 2005, 3:48am UTC](https://forum.kirupa.com/t/array-hittest-difficulties/143927/1 "2005-04-10T03:48:07Z")

</div>

Im trying to do a hit test on individual objects in two seperate arrays.  
one is an array of bullets populated each time the mouse is pressed, the other is an array of enemies that are created at timed intervals. So far I have failed at  
every attempt and I would be extremely grateful for any help.

the code on the stage is as follows:

tick=0;  
int (tock);  
score=0;  
speed = 10;  
depth = 0;  
nose = 50;

aaron = new Array();  
aaron2 = new Array();

for(i=0; i\<\_root.aaron2.length; i++){

if (this.\_parent.hitTest(\_root.aaron2\*)) {  
this.\_parent.removeMovieClip();  
trace(“Hello”);  
\_root.damage=“gghvghv”;  
}  
}

\_root.onMouseMove = function() {  
updateAfterEvent();

};  
\_root.onMouseDown = function() {  
loop\_sound = new Sound();  
loop\_sound.attachSound(“boom.wav”);  
loop\_sound.setVolume(100);  
loop\_sound.start();

angle = cannon.\_rotation;  
angle = angle\*Math.PI/180;  
++depth;  
name = “ball”+depth;

\_root.attachMovie(“ball”, name, depth);  
\_root[name].\_x = cannon.gunref.point.x;  
\_root[name].\_y = cannon.gunref.point.y;  
\_root[name].xmov = speed_Math.cos(angle);  
\_root[name].ymov = speed_Math.sin(angle);

aaron.push(name);

\_root[name].onEnterFrame = function() {

this.\_x += this.xmov;  
this.\_y += this.ymov;  
}

};

//START OF 2ND CODE  
\_root.chopperholder.onEnterFrame = function(){  
\_root.timer=tock;  
\_root.a=tick;  
tock++;  
if(tock\>1000){  
tock=0;  
}  
if(tock==100||tock==300||tock==500||tock==700||tock==900){  
name2 = “blue”+adepth;  
\_root.attachMovie(“blue”, name2, adepth);  
\_root[name2].\_x = chopperholder.chopref.point2.x;  
\_root[name2].\_y = chopperholder.chopref.point2.y;  
adepth++;  
aaron2.push(name2);

}  
}

stop();

then on each of the movie clips i have the following code

onClipEvent(enterFrame) {  
if (this.\_parent.hitTest(\_root.right)) {  
\_root.damage=“Boundary Hit!”;  
this.\_parent.unloadMovie();  
}

if (this.\_parent.hitTest(\_root.top)) {  
\_root.damage=“Boundary Hit!”;  
this.\_parent.unloadMovie();  
}

for(i=0; i\<\_root.aaron2.length; i++){

if (this.\_parent.hitTest(\_root.aaron2\*)) {  
this.\_parent.removeMovieClip();

```
_root.damage="Collision detected";

```

}  
}

}
