# Hit Test between two objects

**URL:** <https://forum.kirupa.com/t/hit-test-between-two-objects/202992>\
**Category:** random\
**Created:** [October 6, 2006, 12:18pm UTC](https://forum.kirupa.com/t/hit-test-between-two-objects/202992 "2006-10-06T12:18:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayur\_GTL](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@mayur\_GTL](https://forum.kirupa.com/u/mayur_GTL)\
**Post date:** [October 6, 2006, 12:18pm UTC](https://forum.kirupa.com/t/hit-test-between-two-objects/202992/1 "2006-10-06T12:18:11Z")

</div>

Thanks for to look in this thread.  
Can any one explain me properly and priciously about hitTest() of MovieClip.  
I am making a game and this hit test problem has been much sticky for me.  
See my problem is :  
(1) one object is droping form the top of the stage towards down side (consider as water level) to sink.

- with random speed of folling objects.
- so I am initialising a random no to random objets (e.g. randomRange(1,7))
- now, what happens that I have a one level consider (e.g. waterLevel) at some size of (\_x = 400 and \_y = 430)  
and my stage size is ( width=400 and height = 460)
- now condition is that every object folling form top should be die if his parachoots is not opened before it touches to waterLevel.
- I increament the \_y property of every fallingObject by this randomly generated Num. cotinuously ( onEnterFrame event )
- so problem is, when I increamet \_y by randomly generated Num for some falling objects hit test does not occur and for some it occurs.
- for my waterLevel I have taken a MovieClip of water color and its shape is ( e.g.ractangular with curve shape like water is shaking/moving ) and in that movie clip I hava taken a dummy movie clip (e.g. emptyWaterMC of ractangular shape) and keep it as \_hitArea of its _parent MovieClip  
!!! ??? 😕 can any one explain me what should I do to get hitTest, always, by incrementing with randomly generated Num. ???  
 **snippet some thing like** \*  
var fallingObj\_MC : MovieClip;  
fallingObj\_MC = target.attachMovie(“abc”,“xyz”,target.getNextHighestDepth ());  
// randomRange(lowNum,hiNum) generates random numers of given range  
var randNum : Number = randomRang(1,7);  
fallingObj_.onEnterFrame = function()  
{  
this.\_y += randNum;  
}  
// now for water Level  
var waterLevel : MovieClip;  
var emptyWater : MovieClip;  
waterLevel.hitArea = emptyWater;  
watchOnWaterLevel.onEnterFrame = fucniton()  
{  
//I am checking hit test here  
if(this.hitTest(fallingObj))  
{  
trace(“hit done”);  
callObjectSink();  
}  
}  
\*\*\*\*\*\* snippet end\*\*\*\*\*\*\*\*\*\*\*\*\*  
Thanking you in advance 🙂
