# Popping bubble wrap HitTest

**URL:** <https://forum.kirupa.com/t/popping-bubble-wrap-hittest/328194>\
**Category:** flash\
**Created:** [April 25, 2012, 7:09pm UTC](https://forum.kirupa.com/t/popping-bubble-wrap-hittest/328194 "2012-04-25T19:09:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![POPBA](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@POPBA](https://forum.kirupa.com/u/POPBA)\
**Post date:** [April 25, 2012, 7:09pm UTC](https://forum.kirupa.com/t/popping-bubble-wrap-hittest/328194/1 "2012-04-25T19:09:38Z")

</div>

Hi, thank you all for the good tips 🙂 they helped me go forward in my project!

I’m working on this not-new-idea of bursting bubble warp. I figured it’s a good way of learning . But I’m missing something and can’t quite figure it out.

I have a movie clip called “button\_mc” that has the 3 states of the bubble:  
-A starting state “\_up”,  
-Cracking the bubble “\_down” ( because this one has the popping sound);

- and cracked “\_downQuiet” ( the same without the noise) .

I would like to be able to pop the bubbles with the mouse click and stay popped.  
I found this code that works ( thanks guys for the hitTest tutorial!):

onMouseDown= function () {  
mx=\_xmouse;  
my=\_ymouse;  
if (button\_mc.hitTest(mx, my)) {  
button\_mc.gotoAndPlay("\_down");  
}  
}

BUT… if i click again on top it replays the \_down with sound… which is not the idea because the bubble is already popped.  
So i tried to add and “else”. but it didn’t work :S

onMouseDown= function () {  
mx=\_xmouse;  
my=\_ymouse;  
if (button\_mc.hitTest(mx, my)) {  
button\_mc.gotoAndPlay("\_down");  
}  
else {gotoAndPlay("\_downQuiet");  
}

}

What am I doing wrong? Some help would be appreciated.

Plus one more thing. I wanted to go real pro and make 4 or 5 kinds so it gives a realistic effect But 4 or 5 wont be enough to fill the scene. Would i have to duplicate the MC’s, change the name and make a separate code for each bubble? I guess this shows that I’m a newbie.

Thanks already for the help!!
