# Hittesting two or more buttons

**URL:** <https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297>\
**Category:** Uncategorized\
**Created:** [August 12, 2003, 10:13am UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297 "2003-08-12T10:13:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheMerryMaker](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@TheMerryMaker](https://forum.kirupa.com/u/TheMerryMaker)\
**Post date:** [August 12, 2003, 10:13am UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297/1 "2003-08-12T10:13:39Z")

</div>

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?

---

<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:** [August 12, 2003, 10:26am UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297/2 "2003-08-12T10:26:06Z")

</div>

Sorry no flash with me, so what code did you use? Try the ‘&&’ thing, although i’ve never used it before :-\

---

<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:** [August 12, 2003, 11:36am UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297/3 "2003-08-12T11:36:27Z")

</div>

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.

---

<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:** [August 12, 2003, 11:55am UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297/4 "2003-08-12T11:55:16Z")

</div>

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…

---

<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:** [August 12, 2003, 12:02pm UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297/5 "2003-08-12T12:02:53Z")

</div>

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 :-\

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

oh yea you havta make the btns overlap at one point or it’ll never work 😉

---

<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:** [August 12, 2003, 9:04pm UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297/6 "2003-08-12T21:04:12Z")

</div>

i got it to work using the “||” insted or the “&&”. does anyone else know of an easier way?

---

<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:** [August 12, 2003, 9:38pm UTC](https://forum.kirupa.com/t/hittesting-two-or-more-buttons/28297/7 "2003-08-12T21:38:25Z")

</div>

Put your buts in one mc and hitTest that 😉

this way you wouldn’t need the

```auto

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

```
