# Need help with Collision Detected \<hitTest\>

**URL:** <https://forum.kirupa.com/t/need-help-with-collision-detected-hittest/106221>\
**Category:** Uncategorized\
**Created:** [April 3, 2004, 11:08am UTC](https://forum.kirupa.com/t/need-help-with-collision-detected-hittest/106221 "2004-04-03T11:08:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![puthisorn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@puthisorn](https://forum.kirupa.com/u/puthisorn)\
**Post date:** [April 3, 2004, 11:08am UTC](https://forum.kirupa.com/t/need-help-with-collision-detected-hittest/106221/1 "2004-04-03T11:08:58Z")

</div>

Please help me. I’m the beginner in actionscript  
I’m try to make the Collision Detected with hitTest for long time but it doesn’t work. I have two objecct one is the Spaceship and rock. When those two hit each other. I want it to show text “Collision Detected”  
This is my script

Frame1 script

var rockCount = 0;  
var rockTimeGap = 1;  
var nextRockTime = 0;  
var startTime = getTimer();  
stop();

MyTimer script  
onClipEvent (enterFrame) {  
timeElapsed = Math.round((getTimer()-\_root.startTime)/1000);  
if (timeElapsed\>=\_root.nextRockTime) {  
\_root.rockCount++;  
//\_global.RockNum = \_root.rockCount;  
newRock = \_root.rock.duplicateMovieClip(‘rock’+\_root.rockCount, 100+\_root.rockCount);  
//trace(‘rock’+\_root.rockCount)  
newScale = Math.random()\*80+50;  
newRock.\_xscale = newScale;  
newRock.\_yscale = newScale;  
//set the start edge of new rock  
newRock.\_x = Math.random()\*550;  
newRock.\_y = Math.random()\*10;  
\_root.nextRockTime += \_root.rockTimeGap;  
}

}

Script in Spaceship MC  
onClipEvent (enterFrame) {  
if (\_root.Spaceship, hitTest(‘rock’+\_root.rockCount)) {  
trace(‘rock’+\_root.rockCount)  
\_root.text = “Collision Detected”;  
} else {  
\_root.text = “No Collision”;  
}  
}  
The above is Flash MX actionscript
