# (FMX) hitTesting

**URL:** <https://forum.kirupa.com/t/fmx-hittesting/26001>\
**Category:** Uncategorized\
**Created:** [July 18, 2003, 1:16pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001 "2003-07-18T13:16:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![luster](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@luster](https://forum.kirupa.com/u/luster)\
**Post date:** [July 18, 2003, 1:16pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/1 "2003-07-18T13:16:10Z")

</div>

Does anyone here know why hitTest doesn’t work?  
(Look at score)  
I tried loooooooots of things, but none of them worked.

---

<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:** [July 18, 2003, 3:14pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/2 "2003-07-18T15:14:40Z")

</div>

the hitTest works, it’s just that your coding is a bit screwed up

here’s what i think the problem is: you check the hitTest for the \_root[“bom”+i] when you actually incremented the i variable for the next bomb…

which means that when the bomb drop on the house the hitTest won’t work because the house is waiting for the bomb that’s coming after, and so on

to be sure i changed the i to a certain value (because the first two bombs always dropped on their own, dunno why), bom3  
and it worked

```auto

onClipEvent (enterFrame) {
        if (_root["bom"+3].hitTest(_root.chalethuis)) {
		trace("bomb works")	
                _root.score = _root.score +1 ;
                
        }
}

```

what i would recommend is to actually create a function with the hitTest() and then apply that function to each bomb… (using coding of course)

of it helped =)

mlk

---

<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:** [July 18, 2003, 3:37pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/3 "2003-07-18T15:37:45Z")

</div>

First, thanks for reply.  
But it doesn’t work fully on my PC.  
Can you post a .fla please?

PS What’s the “trace” for?

---

<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:** [July 18, 2003, 6:22pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/4 "2003-07-18T18:22:14Z")

</div>

Here’s my second .fla. I made some minor changes to the “chalethuis” code and I limited bomb use.  
Can anyone find the bug?

---

<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:** [July 19, 2003, 11:59am UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/5 "2003-07-19T11:59:24Z")

</div>

Anyone?

---

<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:** [July 19, 2003, 12:18pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/6 "2003-07-19T12:18:45Z")

</div>

> _Originally posted by mlkdesign_  
> **and then apply that function to each bomb…**

That’s the key, luster.  
[AS]// bomb actions  
onClipEvent (load) {  
bomMoveSpeed = 20;  
this.\_x = \_root.vliegtuigje.\_x;  
this.\_y = \_root.vliegtuigje.\_y+10;  
}  
onClipEvent (enterFrame) {  
this.\_y += bomMoveSpeed;  
if (this.hitTest(\_root.chalethuis)) {  
\_root.score++;  
this.removeMovieClip();  
}  
if (this.\_y\>400) {  
this.removeMovieClip();  
}  
}[/AS]

---

<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:** [July 19, 2003, 12:49pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/7 "2003-07-19T12:49:28Z")

</div>

Thanks for all the helpful replies. There’s only one little problem. If I copy “chalethuis” , it doesn’t hitTest with the copy. I solved this by giving it another instance name and adding some code, now it works fine, but is there an explanation for that? Just a question.  
But, ALL THANKS FOR REPLYING!!!

---

<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:** [July 19, 2003, 1:08pm UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/8 "2003-07-19T13:08:07Z")

</div>

Sorry! But why doesn’t it play “ontploffing”?

---

<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:** [July 20, 2003, 9:53am UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/9 "2003-07-20T09:53:33Z")

</div>

? Anyone?

---

<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:** [July 20, 2003, 10:50am UTC](https://forum.kirupa.com/t/fmx-hittesting/26001/10 "2003-07-20T10:50:56Z")

</div>

[AS]\_root.chalethuis.gotoAndPlay(“ontploffing”);[/AS]  
:sigh:
