# Shooting with loading times

**URL:** <https://forum.kirupa.com/t/shooting-with-loading-times/175776>\
**Category:** programming\
**Created:** [January 17, 2006, 6:57pm UTC](https://forum.kirupa.com/t/shooting-with-loading-times/175776 "2006-01-17T18:57:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sammo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sammo/32/779_2.png) [@Sammo](https://forum.kirupa.com/u/Sammo)\
**Post date:** [January 17, 2006, 6:57pm UTC](https://forum.kirupa.com/t/shooting-with-loading-times/175776/1 "2006-01-17T18:57:27Z")

</div>

```auto
MovieClip.prototype.mover = function(speedStop, remove) {
	this.speed *= speedStop, this.rad = this._rotation * (Math.PI / 180);
	if (remove) {
		(this._y <= 0 || this._y >= 500 || this._x <= 0 || this._x >= 650) ? this.removeMovieClip() : null;
	} else {
		this._x <= 0 ? this._x = 650 : this._x >= 650 ? this._x = 0 : null;
		this._y <= 0 ? this._y = 500 : this._y >= 500 ? this._y = 0 : null;
	}
	this._x += Math.sin(this.rad) * this.speed;
	this._y -= Math.cos(this.rad) * this.speed;
};
load1 = load2 = true;
MovieClip.prototype.shoot = function (player) {
	j = (1+j)%1000;
	_root["load"+player] = false;
	b = attachMovie("bolt","bolt"+j,j+11000);
	b._x = this._x, b._y = this._y, b._rotation = this._rotation;
	b.gotoAndStop(player);
	b.speed = this.speed+5;
	b.onEnterFrame = function () {
		this.speed++;
		this.mover(.91, true);
	}
	if (!_root["load"+player]) {
		this["loading"+player] = setInterval(loadGun, 300, player);
	}
}
function loadGun (playno) {
	_root["load"+playno] = true;
	clearInterval(this["loading"+payer]);
}

```

3 functions to deal with shooting. Called everyframe like so:

```auto
Key.isDown(96) ? ((load1) ? player1.shoot(1): null) : null;

```

This works fun when the num 0 key (key 96) is pressed, but once it’s released and press again it fires two shots a time, then three, four, etc.

Why is it doing this?
