Help please! Confusion with hitTest

I am entirely new to this and am having difficulty getting the hitTest method to work in conjunction with an on (anything) command. I’m simply trying to have the program properly recognize when I have a button moved over a movie clip and have pressed down. In this, the button moves to wherever the cursor is.

If I put the code concerning this into the movie clip, and have it look like this (“otter” is the button, “enemy” is the movie clip, and “text” is a textfield):

onClipEvent (enterFrame) {
if (_root.enemy, hitTest(_root.otter)) {
_root.text = _root.text + 1;
}

It works just fine, running up the text box really quickly when I move the button over the movie clip. But, if I put the code I really want into the button, like this:

on (press) {
if (_root.enemy, hitTest(_root.otter)) {
_root.text = _root.text + 1;
}
}

It doesn’t work at all. No matter where I click on the screen, it thinks they’re hitting each other. I tried changing “press” to “rollOver”, and it thinks they’ve connected whenever I move the cursor onto the flash screen, even if they’re very far away from each other. I tried “keypress <Enter>” and it didn’t even matter if the cursor was on the flash screen or not. It just kept adding up with every press. Please help me, thanx!

-Xakyrie

hrm, I think it could be that hitTest has to be within an onClipEvent…unless your “on” is within an onClipEvent, I dunno.

note: I don’t understand why you’ve got two conditionals within your if statement…is there a trick here that I don’t know about? does the “,” substitute for an || or an &&??? :wink:

just reread before hitting submit: if you have an “on (press)” within a movie clip, does it really do anything? I thought “on(press)”'s were only for buttons!

onClipEvent(enterFrame){
if (this.hitTest(_root.otter)){
_root.gotoAndPlay(2);}}