PDA

View Full Version : hittesting two or more buttons



TheMerryMaker
August 12th, 2003, 06:13 AM
thanks to you guys iv gotten hittest to work on me and my friends sites, but with olny one button for the MC to check for. Very simply, how do i get it to check for 2 or more?

blah-de-blah
August 12th, 2003, 06:26 AM
Sorry no flash with me, so what code did you use? Try the '&&' thing, although i've never used it before :-\

TheMerryMaker
August 12th, 2003, 07:36 AM
hehe, weird. i just found the && thing and tryed it. no luck. im not really sure what the syntax is for that or arrays which im fooling around with now. also, i accidently made the second "button" a MC in my fla, but that can be easy fixed.

blah-de-blah
August 12th, 2003, 07:55 AM
Well i usually never use buttons, even if they act as 'buttons', i still keep em as MC's...I'll have a look at your fla now. It may or may not work :-\

EDIT: just looked at it...you want the mouse to hitTest both the blue boxes?? Thats not possible cause they're not overlapping each other. Your mouse can only be at one place at a time...

blah-de-blah
August 12th, 2003, 08:02 AM
Ok here it is. I changed the darker blue button's instance name to 'btn2', because you shouldn't start instance names or variables with a number...

This can probably be shorter i dunno :-\


onClipEvent (enterFrame) {
if (_root.btn.hitTest(_root._xmouse, _root._ymouse, true)&& _root.btn2.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}


oh yea you havta make the btns overlap at one point or it'll never work ;)

TheMerryMaker
August 12th, 2003, 05:04 PM
i got it to work using the "||" insted or the "&&". does anyone else know of an easier way?

Johnny64
August 12th, 2003, 05:38 PM
Put your buts in one mc and hitTest that ;)

this way you wouldn't need the


Button.prototype.hitTest = MovieClip.prototype.hitTest;