# Another hitTest question - help

**URL:** <https://forum.kirupa.com/t/another-hittest-question-help/65659>\
**Category:** Uncategorized\
**Created:** [September 28, 2004, 3:56pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659 "2004-09-28T15:56:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![basefetish](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@basefetish](https://forum.kirupa.com/u/basefetish)\
**Post date:** [September 28, 2004, 3:56pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/1 "2004-09-28T15:56:29Z")

</div>

Lets say I have 5 layers in my movie, with two MCs, one on layer 1, another on layer 5.

I want the MC on layer 1 to when it is hit by MC on layer 5, to goto and play frame two on the main timeline.

Is it necessary to define what \_levels the MC are on to properly use the hitTest function?

And where would my hitTest code be?  
on both MC’s? or on my action layer in frame one?

might be a stupid question, but to me, no questions are stupid in the quest for learning…

thanks greg

---

<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:** [September 28, 2004, 4:53pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/2 "2004-09-28T16:53:44Z")

</div>

[http://www.kirupa.com/developer/actionscript/hittest.htm](http://www.kirupa.com/developer/actionscript/hittest.htm)

---

<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:** [September 28, 2004, 5:24pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/3 "2004-09-28T17:24:51Z")

</div>

layers don’t mean squat (except depth properties) when it comes to playing the movie.

you can use hitTest the same way no matter what layers the movieclips are on

---

<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:** [September 28, 2004, 7:15pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/4 "2004-09-28T19:15:06Z")

</div>

thanks, I’ll check it out…

greg

---

<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:** [September 28, 2004, 10:17pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/5 "2004-09-28T22:17:52Z")

</div>

ok what I’m doing is not working, I can get the simple hittest function to work with the hittest.fla example, but when I transfer it to my movie, no dice.

Here is the source code, if it helps at all, basically what I want to happen is if the cockpit hits the bottom of the boundary box, then a crash happens…

use the stick to fly, the box will come into view

thanks

---

<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:** [September 29, 2004, 3:56am UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/6 "2004-09-29T03:56:11Z")

</div>

someone can correct me if i am wrong…but i think the way that you have it set up rightnow, the hitTest won’t work. Because rightnow, your white Box mc is directly below the dune, so they’re constantly hitting each other. If you were to put a trace on the white box, you’d see what i’m talking about.

Put this on the white box mc in place of what you have to see:  
[AS]  
onClipEvent (enterFrame) {  
if (\_root.dune, hitTest(this)) {  
trace(“crash”);  
}  
}  
[/AS]

---

<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:** [September 29, 2004, 3:12pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/7 "2004-09-29T15:12:34Z")

</div>

ok, i’ve tried it, and still the same, no matter what layer or where I place the box, no love.

I changed the box to a small circle and still same results, even when I place off screen and not touching any other MC.

NOw the simple hittest code works in a movie with nothing else in it, when I copy the code and try to run it, no love, again. see the attached file. turn right the boxes hit, but no hitest function…

would it be because I am running all the actions in frame 1 for the fligth dynamics?

help please.

---

<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:** [September 29, 2004, 3:24pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/8 "2004-09-29T15:24:01Z")

</div>

```auto
onClipEvent (enterFrame) {
	if (_root.circle, hitTest(_root.block)) {
		gotoAndPlay(stop);
	}
}

```

ok… you need to change to this:

```auto
onClipEvent (enterFrame) {
	if (_root.circle.hitTest(_root.block)) {
		gotoAndPlay(stop);
	}
}

```

also, i don’t think

```auto
gotoAndPlay(stop);

```

is a valid line of code. if your aim here is to stop the movieclip, the use

```auto
stop();

```

hope this helps 🙂

---

<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:** [September 29, 2004, 5:58pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/9 "2004-09-29T17:58:15Z")

</div>

thanks for the reply, but no dice, even when removing everything out, but the joystick and two circles with the approriate code. it seems that when the MCs are controlled by the joystick the hittest function no workie. but when the circles are left to their own, it works.

I named a frame as ‘stop’, for my line, I just wanted it to do something, so I knew the hittest function worked

oh well, welcome to my personal hell. more trial and error I guess.

thanks all to who replied…

---

<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:** [September 29, 2004, 6:35pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/10 "2004-09-29T18:35:48Z")

</div>

ah - i found your problem. it was because you named the second circle “box1” but in the code you referred to it as block

you need to use:

```auto
onClipEvent (enterFrame) {
	if (_root.circle.hitTest(_root.box1)) {
		trace("ok");
	}
}

```

that is where your problem lies.

hope this helps. btw - that looks really nice 🙂

---

<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:** [September 29, 2004, 6:56pm UTC](https://forum.kirupa.com/t/another-hittest-question-help/65659/11 "2004-09-29T18:56:39Z")

</div>

ahh yes, thanks that helps, let me plug it into my main movie with scolling background.
