# \[mx\] laser shooter

**URL:** https://forum.kirupa.com/t/mx-laser-shooter/13079
**Category:** flash
**Created:** [February 8, 2003, 4:57pm UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079 "2003-02-08T16:57:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![zylum](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zylum](https://forum.kirupa.com/u/zylum)
#### Post date: [February 8, 2003, 4:57pm UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079/1 "2003-02-08T16:57:15Z")

</div>

Hi, I’m fairly new at flash,

I’m working on a new project, its a side scrolling game where an airplane (user) has to shoot down a bunch of other enemy planes. I was wondering how to create an AS to shoot lasers from the nose of the plane… any help would be appreciated…:crazy:

thanks in advance!

---

<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: [February 8, 2003, 5:17pm UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079/2 "2003-02-08T17:17:15Z")

</div>

Tute is on the way 🙂

---

<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: [February 8, 2003, 5:52pm UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079/3 "2003-02-08T17:52:43Z")

</div>

HAHA, that is kinda funny. Kirupa just mentioned the tute he was working on about something like that 😛

---

<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: [February 8, 2003, 6:09pm UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079/4 "2003-02-08T18:09:47Z")

</div>

[swf=“[http://www.fantom-stranger.com/~mentalconcepts/freedomFighter.swf](http://www.fantom-stranger.com/~mentalconcepts/freedomFighter.swf) height=400 width=550”][/swf]

You mean something like this?

---

<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: [February 8, 2003, 6:16pm UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079/5 "2003-02-08T18:16:49Z")

</div>

yea, like that playamarz, except that the ship is able to move on the x axis… other than that, its exactly the same… can i see the AS you used, it would be really helpful,

thanks=)

---

<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: [February 8, 2003, 11:23pm UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079/6 "2003-02-08T23:23:28Z")

</div>

I tried using this AS…

lsrSpd = 0;  
laser.\_visible = false;  
bullet.\_x = px;  
bullet.\_y = py;  
px = user.\_x;  
py = user.\_y;

bullet.onEnterFrame = function() {  
if (Key.isDown(Key.SPACE)) {  
lsrSpd = 10;  
px += lsrSpd;  
this.\_visible = true;  
}  
}

the laser follows the nose of the plane and when the space bar is pressed, the laser becomes visible. The thing is that the laser doesn’t move accross the screen, it keeps following the nose of the plane…

any help would 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: [February 9, 2003, 7:09am UTC](https://forum.kirupa.com/t/mx-laser-shooter/13079/7 "2003-02-09T07:09:45Z")

</div>

Here… Well nevermind… Server is down for now… But… Here I’ll post my script…

This is found in the first frame :

```php

MovieClip.prototype.fireShot = function (startx, starty, xdir, ydir)
{
	duplicateMovieClip(this, "bullet"+next, next);
	_root["bullet"+next]._x = startx;
	_root["bullet"+next]._y = starty;
	_root["bullet"+next]._xvel = xdir;
	_root["bullet"+next]._yvel = ydir;
	if(next<1000){next++;}else{next=0;}
}
_root.stanShot.onLoad = function()
{
	mouse.hide();
	next = 10;
	addon = 0;
	stanTimer = 0;
	shotTimer = 0;
}
_root.onEnterFrame = function()
{
	_root.plane._y = _root._ymouse;
	_root.addongun._y = _root.plane._y;
	if(Key.isDown(48))
	{
		addon = 0;
		removeMovieClip(addongun);
	}
	if(Key.isDown(49))
	{
		addon = 1;
		removeMovieClip(addongun);
		duplicateMovieClip(spreader, "addongun", 3000);
		_root.addongun._x = _root.plane._x;
		_root.addongun._y = _root.plane._y;
	}
	if(Key.isDown(50))
	{
		addon = 2;
		removeMovieClip(addongun);
		duplicateMovieClip(macgun, "addongun", 3000);
		_root.addongun._x = _root.plane._x;
		_root.addongun._y = _root.plane._y;
	}
	if(Key.isDown(51))
	{
		addon = 3;
		removeMovieClip(addongun);
		duplicateMovieClip(bag, "addongun", 3000);
		_root.addongun._x = _root.plane._x;
		_root.addongun._y = _root.plane._y;
	}
	if(stanTimer>0){stanTimer--;}
	if(shotTimer>0){shotTimer--;}
}
_root.onMouseDown = function()
{
	if(stanTimer == 0)
	{
		_root.stanShot.fireShot(plane._x+30, plane._y, 7.5, 0);
		stanTimer = 10;
	}
	if(addon == 1 && shotTimer == 0)
	{
		_root.stanShot.fireShot(plane._x, plane._y+20, 7.5, 0);
		_root.stanShot.fireShot(plane._x-3, plane._y+28, 7.5, 3.5);
		_root.stanShot.fireShot(plane._x-10, plane._y+34, 7.5, 6.25); 
		shotTimer = 18;
	}
	if(addon == 2 && shotTimer == 0)
	{
		_root.stanShot.fireShot(plane._x+5, plane._y+25, 8.5, 0);
		shotTimer = 2;
	}
	if(addon == 3 && shotTimer == 0)
	{
		_root.stanShot.fireShot(plane._x, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+5, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+10, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+15, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+10, plane._y+20, 7.5, 0);
		_root.stanShot.fireShot(plane._x+10, plane._y+30, 7.5, 0);
		shotTimer = 28;
	}
}

```

This piece of code howveer… Is ;ocated int he bullet movieclip…

```php

onClipEvent(load)
{
	this._xscale = 50;
	this._yscale = 50;
}
onClipEvent(enterFrame)
{
	this._x += this._xvel;
	this._y += this._yvel;
	
	if(this._x > 550)
	{
		removeMovieClip(this);
	}
}

```

Have fun… hehe… It should be pretty readable… Albeit… If you need me to break it down some… I can.
