# .hitTest

**URL:** https://forum.kirupa.com/t/hittest/10451
**Category:** flash
**Created:** [January 1, 2003, 2:22pm UTC](https://forum.kirupa.com/t/hittest/10451 "2003-01-01T14:22:53Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![aqua\_fox](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@aqua\_fox](https://forum.kirupa.com/u/aqua_fox)
#### Post date: [January 1, 2003, 2:22pm UTC](https://forum.kirupa.com/t/hittest/10451/1 "2003-01-01T14:22:53Z")

</div>

There is something wrong with this…  
WHAT?😱😱😱!

OnClipEvent(load){  
if (this.hitTest(\_root.coll)){  
gotoAndPlay(2)  
}}  
PS I am using FLASH 5:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 1, 2003, 2:52pm UTC](https://forum.kirupa.com/t/hittest/10451/2 "2003-01-01T14:52:36Z")

</div>

I have no idea what you are trying to create with that script but…  
Make sure that the code is on the movieclip which collision is being detected!  
Make sure “coll” is one the main timeline!  
Make sure if you need anything in front of gotoAndPlay(); like \_root. or something because it will go and play frame 2 inside the movieclip that collision is being detected!  
And finally I think this is the problem  
Change onClipEvent(load) {} to onClipEvent(enterFrame) {}  
onClipEvent(load) will execute the actions within it once the movieclip has appeared on the stage but onClipEvent(enterFrame) will trigger the actions yourfps/second! So if your fps is 20 it will trigger the actions 20 times in a second! So it detects the collision every moment not just in the beginning!  
One of thses has got to be the problem!:pirate:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 1, 2003, 2:55pm UTC](https://forum.kirupa.com/t/hittest/10451/3 "2003-01-01T14:55:27Z")

</div>

1. onClipEvent is case senitive. (you have OnClipEvent)

2. be aware that load events occur before internal frame events. So if you have a stop() on frame 1 of this movieclip, it will be called AFTER this load script so if that clip is hittesting true on coll, then it will gotoAndPlay on frame 2 then run the stop() call in frame 1 of the clip if it exists. Not exactly a problem with that code, but the problem has the potential to exist.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 4, 2003, 8:42pm UTC](https://forum.kirupa.com/t/hittest/10451/4 "2003-01-04T20:42:07Z")

</div>

Might wnana change this:

onClipEvent(enterFrame)

Instead of load…

Cause it’ll just laod the movieclip… Execute that line of code… And that’s it… If you wnat it to loop around and everytime it enters the fraem. Chekc to see if it hitTest’s… use the enterFrame command…

Peace

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 21, 2003, 10:35am UTC](https://forum.kirupa.com/t/hittest/10451/5 "2003-01-21T10:35:42Z")

</div>

Ok… If I type gotoAndPlay(2) it will play the 2nd frame of the timelin.  
So, how do you make it play 2nd frame in the main timeline?:hangover:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 21, 2003, 1:38pm UTC](https://forum.kirupa.com/t/hittest/10451/6 "2003-01-21T13:38:51Z")

</div>

it’s \_root.gotoAndPlay();

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 22, 2003, 7:48am UTC](https://forum.kirupa.com/t/hittest/10451/7 "2003-01-22T07:48:34Z")

</div>

OK… What’s wrong with this?
