# Multiple Hittest

**URL:** <https://forum.kirupa.com/t/multiple-hittest/275190>\
**Category:** flash\
**Created:** [November 11, 2008, 2:04am UTC](https://forum.kirupa.com/t/multiple-hittest/275190 "2008-11-11T02:04:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbuck](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jbuck](https://forum.kirupa.com/u/jbuck)\
**Post date:** [November 11, 2008, 2:04am UTC](https://forum.kirupa.com/t/multiple-hittest/275190/1 "2008-11-11T02:04:26Z")

</div>

Hello,

I am creating a game where a shopper moves horizontally in a store and runs into different items. When the shopper "hits’ an item, he/she displays a speech bubble identifying the item (produce, milk, shopping bag, etc…). I realize that I need to utilize a multiple hittest between the shopper (shopper\_mc) and the many items in the store (shopping\_bag\_mc, produce\_mc, milk\_mc, etc…).

Here is my current code which resides in a movie clip called background\_mc and it does not work:

function hit(){  
if (\_root.shopper\_mc.keyFlag==false){  
////////////////item1///////////////////  
if (\_root.shopper\_mc.hitTest(info\_desk\_mc)){  
\_root.shopper\_mc.attachMovie(“speech\_info\_desk\_mc”, “instance1”, 1, {\_x:-28, \_y:-235});  
\_root.text = “Info Desk Detected”;  
}  
////////////////item2///////////////////  
if (\_root.shopper\_mc.hitTest(shopping\_bag\_mc)){  
//\_root.shopper\_mc.attachMovie(“speech\_shopping\_bag\_mc”, “instance1”, 1, {\_x:-28, \_y:-235});  
\_root.text = “Shopping Bag Detected”;  
}  
////////////////item3///////////////////  
if (\_root.shopper\_mc.hitTest(radio\_mc)){  
//\_root.shopper\_mc.attachMovie(“speech\_radio\_mc”, “instance1”, 1, {\_x:-28, \_y:-235});  
\_root.text = “Radio Detected”;  
}  
} else {  
\_root.shopper\_mc.createEmptyMovieClip(“empty\_mc”, 1);  
\_root.text = “No Item Detected”;  
}  
}  
setInterval(hit,4);

Thanks ahead of time for any help
