# I can fire my spray but how to i nail that butterfly?

**URL:** <https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911>\
**Category:** flash\
**Created:** [September 30, 2004, 3:26pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911 "2004-09-30T15:26:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricardinho](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@Ricardinho](https://forum.kirupa.com/u/Ricardinho)\
**Post date:** [September 30, 2004, 3:26pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/1 "2004-09-30T15:26:38Z")

</div>

So im making a game … very very very simple one… ive created my bug killing spray and also the enemy butterfly… but what do you do now to make the butterfly die when its hit with the spray droplets?

---

<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:** [September 30, 2004, 4:12pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/2 "2004-09-30T16:12:07Z")

</div>

A collision detection! When the spray contacts the insect you get a dead insect, so gotoAndPlay a dying sequence or something in your butterfly movieclip.

---

<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:** [September 30, 2004, 5:09pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/3 "2004-09-30T17:09:54Z")

</div>

yeah i tried the collision detection but it wouldn’t work… i named the mc (instance) and attached the collision detection actions to the spray (“bullet”) part of the game but no detection ever happened… im doing all this by the way using the tutorial from this site… so i checked the fire tut and the collsision detection tut and have tried to combine with out success…

heres the AS …

on the spray or otherwise none as the “bullet”:

> 

onClipEvent (load) {  
this.\_visible = 0;  
if (\_root.fire == 1) {  
this.\_x = \_root.Spray.\_x;  
this.\_y = \_root.Spray.\_y;  
}  
}  
onClipEvent (enterFrame) {  
if (this != \_level0.bullet) {  
if (\_root.fire == 1) {  
this.\_x -= -10;  
this.\_visible = 1;  
}  
if (this.\_x\<0) {  
this.removeMovieClip();  
}  
}  
}  
onClipEvent (enterFrame) {  
if (\_root.bullet, hitTest(\_root.bf)) {  
\_root.bf = gotoAndPlay (2);  
} else {  
\_root.bf = gotoAndStop (1);  
}  
}

the other part of all this is the “spray” bottle which is a button that when pressed fires the “bullet” which in theory when it hits that little butterfly (“bf”) should detect a collsision and nail it…but nothing??

hope thats not to complicated sounding

---

<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:** [September 30, 2004, 9:48pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/4 "2004-09-30T21:48:52Z")

</div>

anyone got any ideas?

---

<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:** [October 1, 2004, 3:35pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/5 "2004-10-01T15:35:23Z")

</div>

here’s a demo .fla … :h:

---

<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:** [October 1, 2004, 4:57pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/6 "2004-10-01T16:57:14Z")

</div>

nobody got a clue then.

---

<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:** [October 1, 2004, 8:30pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/7 "2004-10-01T20:30:50Z")

</div>

help

---

<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:** [October 2, 2004, 2:06am UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/8 "2004-10-02T02:06:24Z")

</div>

I tried modifying it, but no matter what I did, even though it logically should of worked, it didn’t.

---

<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:** [October 2, 2004, 7:22am UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/9 "2004-10-02T07:22:58Z")

</div>

Your code is actually working. The problem is that you have several “bullets”(not mc) firing at once sometimes hitting,sometimes missing so the text will not change.  
try  
onClipEvent (enterFrame) {  
if (\_root.bullet, hitTest(\_root.butter)) {  
\_root.text += 1;  
} else {  
trace(“missed”);  
}  
}

nb/text is not such a good name for a variable

---

<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:** [October 2, 2004, 10:54am UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/10 "2004-10-02T10:54:56Z")

</div>

i did try only one bullet but it still would not work… heres another .fla , this one is the fire tutorial from this site modified with the hitTest actions taken from the collision detection tutorial from this site… only one bullet but still no detection…

---

<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:** [October 2, 2004, 11:02am UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/11 "2004-10-02T11:02:13Z")

</div>

couldn’t upload it but try it for yourself if you like… its in the flash mx tutorial section…

---

<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:** [October 2, 2004, 1:01pm UTC](https://forum.kirupa.com/t/i-can-fire-my-spray-but-how-to-i-nail-that-butterfly/65911/12 "2004-10-02T13:01:03Z")

</div>

> [@Ricardinho](#):
>
> couldn’t upload it but try it for yourself if you like… its in the flash mx tutorial section…

see if this helps.
