Another hitTest question - help

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

http://www.kirupa.com/developer/actionscript/hittest.htm

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

thanks, I’ll check it out…

greg

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

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]

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.

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

ok… you need to change to this:

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

also, i don’t think

gotoAndPlay(stop);

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

stop();

hope this helps :slight_smile:

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…

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:

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

that is where your problem lies.

hope this helps. btw - that looks really nice :slight_smile:

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