# They won't fire...\[MX\]

**URL:** <https://forum.kirupa.com/t/they-wont-fire-mx/96488>\
**Category:** Uncategorized\
**Created:** [December 10, 2003, 1:46am UTC](https://forum.kirupa.com/t/they-wont-fire-mx/96488 "2003-12-10T01:46:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SetroGamer](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@SetroGamer](https://forum.kirupa.com/u/SetroGamer)\
**Post date:** [December 10, 2003, 1:46am UTC](https://forum.kirupa.com/t/they-wont-fire-mx/96488/1 "2003-12-10T01:46:30Z")

</div>

Neither the player nor enemy will fire at eachother! (That sounds funny, doesn’t it?)  
“YOU”(player)  
[AS]  
on (keyPress “\<Enter\>”) {  
\_root.firey = 1;  
\_root.i += 1;  
duplicateMovieClip(\_root.bullet2, “bullet2”, i);  
}  
[/AS]  
“BULLET2”  
[AS]  
onClipEvent (load) {  
this.\_visible = 0;  
if (\_root.firey == 1) {  
this.\_x = \_root.you.\_x;  
this.\_y = \_root.you.\_y;  
}  
}  
onClipEvent (enterFrame) {  
if (this != \_level0.bullet2) {  
if (\_root.firey == 1) {  
this.\_x += 5;  
this.\_visible = 1;  
}  
if (this.\_x\>0) {  
this.removeMovieClip();  
}  
}  
}  
[/AS]  
“E”(Enemy)  
[AS]  
rand = random(2);  
if (rand == 1) {  
\_root.fire = 1;  
\_root.i += 1;  
duplicateMovieClip(\_root.bullet, “bullet”+i, i);  
}  
[/AS]  
“BULLET”  
[AS]  
onClipEvent (load) {  
this.\_visible = 0;  
if (\_root.fire == 1) {  
this.\_x = \_root.e.\_x;  
this.\_y = \_root.e.\_y;  
}  
}  
onClipEvent (enterFrame) {  
if (this != \_level0.bullet) {  
if (\_root.fire == 1) {  
this.\_x -= 5;  
this.\_visible = 1;  
}  
if (this.\_x\<0) {  
this.removeMovieClip();  
}  
}  
}  
[/AS]  
If you can help, that’d be great 😃

---

<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:** [December 10, 2003, 6:26am UTC](https://forum.kirupa.com/t/they-wont-fire-mx/96488/2 "2003-12-10T06:26:46Z")

</div>

Well… First off, by the looks of it you can shoot as fast as your Enter Key Hitting finger can hit the key… And this is generally unexceptable due to keyboards and their nature… And the fact that you have a variable that isn’t doing anything right now \_root.firey doesn’t help out matters much either…

[AS]  
on (keyPress “\<Enter\>”)  
{  
if(\_root.numMissles \< 10)  
{  
\_root.numMissles++;  
if(\_root.id \< 1000){\_root.id ++;}else{\_root.id=0;}  
\_root.bullet2.duplicateMovieClip(“bullet2”+\_root.id, \_root.id);  
}  
}  
[/AS]

There wer two major problems in this statement…

[AS]  
duplicateMovieClip(\_root.bullet2, “bullet2”, i);  
[/AS]

The first mistake was the “bullet2”. That means that a movie was trying to duplicate itself in its own name. Not good. The second thing to note is the single i. If anything it should be \_root.i since that variable resides on the \_root side and not the actual “you” side…

Now… The next statement…

[AS]  
onClipEvent (load)  
{  
this.\_visible = FALSE;  
if (this.name != “bullet2”)  
{  
this.\_x = \_root.you.\_x;  
this.\_y = \_root.you.\_y;  
}  
}

onClipEvent (enterFrame)  
{  
if (this.name != “bullet2”)  
{  
this.\_x += 5;  
this.\_visible = TRUE;  
if (this.\_x \> 0)  
{  
this.removeMovieClip();  
\_root.numMissles–;  
}  
}  
}  
[/AS]

Now… here are the couple of changes that I made to these couple of lines of code…

[AS]  
onClipEvent (load) {  
this.\_visible = 0;  
if (\_root.firey == 1) {  
this.\_x = \_root.you.\_x;  
this.\_y = \_root.you.\_y;  
}  
}  
onClipEvent (enterFrame) {  
if (this != \_level0.bullet2) {  
if (\_root.firey == 1) {  
this.\_x += 5;  
this.\_visible = 1;  
}  
if (this.\_x \> 500) {  
this.removeMovieClip();  
}  
}  
}  
[/AS]

Now… No need for the firing method. If the bullet clip is on the screen we only want it to do one of three things… Move, Check to see if it hit something, or check to see if it went offscreen. We just need to make sure the clip we are duplicating doesn’t move… Which was named bullet2. So we do a check to make sure bullet2 isn’t going to move. I changed the 0’s and 1’s to FALSE and TRUE… No biggie really… Just so \*\*\*\* used to doing it that way _lmao_ Other than that… It’s good.

BTW… Change the this.\_x \> ### to whatever width your movie is. 🙂

Next statement.

[AS]  
onClipEvent(enterFrame)  
{  
temp = Math.floor(Math.random()\*2);  
if (temp == 1)  
{  
if(\_root.eid \< 1000){\_root.eid ++;}else{\_root.eid = 0;}  
\_root.bullet.duplicateMovieClip(“bullet”+\_root.eid, \_root.eid);  
}  
}  
[/AS]

Just made a couple of quick changes to this one like I did the statement above. and now the last statement.

[AS]  
onClipEvent (load)  
{  
this.\_visible = FALSE;  
if (this.name != “bullet”)  
{  
this.\_x = \_root.e.\_x;  
this.\_y = \_root.e.\_y;  
}  
}

onClipEvent (enterFrame)  
{  
if (this.name != “bullet”)  
{  
this.\_x -= 5;  
this.\_visible = TRUE;  
if (this.\_x \< 0)  
{  
this.removeMovieClip();  
}  
}  
}  
[/AS]

And there you go… Tell me if you are having more problems by e-mailing me. Found in my profile 🙂

---

<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:** [December 10, 2003, 2:02pm UTC](https://forum.kirupa.com/t/they-wont-fire-mx/96488/3 "2003-12-10T14:02:35Z")

</div>

yay! Thank you! 😃

---

<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:** [December 10, 2003, 8:19pm UTC](https://forum.kirupa.com/t/they-wont-fire-mx/96488/4 "2003-12-10T20:19:51Z")

</div>

No problem mate 🍺
