Need help with alternating scripts

Recently I’ve started working on this new game I’ve had the idea of. It’s basically a 2D shooter platformer and the aspect I’m having difficulty with at the moment is the weapon changing. The way I have set it up is there is a Boolean variable for the current weapons. So far I’ve only gotten around to 2 weapons. I wish to have it that if the number 1 key is pressed, the pistol is drawn and if the 2 key is pressed, the shotgun is drawn. I attempted to create this by setting up and if statement for each key. The if statement says that if the 1 key is pressed, the isShotgun variable becomes false and the isPistol variable becomes true. This is vice versa for the other key. The attachment of the gun movie clips are in another if statement asking whether the isShotgun variable is true or the isPistol variable is true. If the if statement passes, it should spawn that weapon and its bullet properties. Unfortunately this does not work for me. As soon as I have one weapon spawned, I can’t switch to the other weapon. I have attached the .fla file for you so if you could help me find the problem, that would be great.

	if (Key.isDown(49))
	{
		isPistol = true;
		isShotgun = false;
	}
	if (Key.isDown(50))
	{
		isShotgun = true;
		isPistol = false;
	}
	if (isPistol)
	{
		tanksg.removeMovieClip();
		if (Key.isDown(50))
		{
			isPistol = false;
		}
		attachMovie("tank","tank",2,{_x:_root.player._x, _y:_root.player._y - 17});
		tank.onEnterFrame = function()
		{
			torch_power = 2000;
			torch_step = 100;
			_root.createEmptyMovieClip("light",_root.getNextHighestDepth());
			dist_x = _root._xmouse - tank._x;
			dist_y = _root._ymouse - tank._y;
			anglel = -Math.atan2(tank._x - _root._xmouse, tank._y - _root._ymouse);
			light.clear();
			light.lineStyle(1,0xffffff,0);
			light.moveTo(tank._x,tank._y);
			ray_angle = anglel / (Math.PI / 180) - 90;
			ray_angle = ray_angle * (Math.PI / 180);
			//light.lineTo(tank._x + (torch_power) * Math.cos(ray_angle),tank._y + (torch_power) * Math.sin(ray_angle));
			//light.lineTo(tank._x,tank._y);
			for (y = 1; y <= torch_step; y++)
			{
				if (ground.hitTest(tank._x + (torch_power / torch_step * y) * Math.cos(ray_angle), tank._y + (torch_power / torch_step * y) * Math.sin(ray_angle), true) || enemy.hitTest(tank._x + (torch_power / torch_step * y) * Math.cos(ray_angle), tank._y + (torch_power / torch_step * y) * Math.sin(ray_angle), true))
				{
					break;
				}
			}
			light.lineTo(tank._x + (torch_power / torch_step * y) * Math.cos(ray_angle),tank._y + (torch_power / torch_step * y) * Math.sin(ray_angle));
			mousex = _xmouse - this._x;
			mousey = (_ymouse - this._y) * -1;
			angle = Math.atan(mousey / mousex) / (Math.PI / 180);
			this._x = _root.player._x;
			this._y = _root.player._y - 17;
			if (mousex < 0)
			{
				angle += 180;
			}
			if (angle > 180)
			{
				angle = 180;
			}
			if (angle < 0)
			{
				angle = 0;
			}
			if (angle < 90)
			{
				this.cannon._yscale = 100;
			}
			else if (angle > 90)
			{
				this.cannon._yscale = -100;
			}
			firepower = 10000;
			this.cannon._rotation = angle * -1;
		};
		var isMouseDown:Boolean = false;
		var bulletReady:Boolean = true;
		var bulletDelay:Number = 250;
		this.onMouseDown = function()
		{
			isMouseDown = true;
		};
		this.onMouseUp = function()
		{
			isMouseDown = false;
		};
		_root.onEnterFrame = function()
		{
			if (isMouseDown && bulletReady)
			{
				bulletReady = false;
				currentTime = getTimer();
				angle = tank.cannon._rotation - 1;
				start_ball_x = tank._x + 47 * Math.cos(angle * Math.PI / 180);
				start_ball_y = tank._y + 47 * Math.sin(angle * Math.PI / 180);
				cannonball_fired = _root.attachMovie("cannonball", "cannonball_" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
				cannonball_fired.dirx = Math.cos(angle * Math.PI / 180) * firepower;
				cannonball_fired.diry = Math.sin(angle * Math.PI / 180) * firepower;
				cannonball_fired.onEnterFrame = function()
				{
					this._x += this.dirx / 50;
					this._y += this.diry / 50;
					if (_root.ground.hitTest(this._x, this._y, true))
					{
						this.removeMovieClip();
					}
					if (enemy.hitTest(tank._x + (torch_power / torch_step * y) * Math.cos(ray_angle), tank._y + (torch_power / torch_step * y) * Math.sin(ray_angle)))
					{
						enemy.swapDepths(_root.getNextHighestDepth());
						enemy.removeMovieClip();
					}
				};
				tank.cannon.play();
			}
			else
			{
				if (currentTime + bulletDelay <= getTimer())
				{
					bulletReady = true;
				}
			}
		};
	}
	else if (isShotgun)
	{
		tank.removeMovieClip();
		if (Key.isDown(49))
		{
			isShotgun = false;
		}
		attachMovie("tankshotgun","tanksg",2,{_x:_root.player._x, _y:_root.player._y - 17});
		tanksg.onEnterFrame = function()
		{
			torch_power = 300;
			torch_step = 100;
			torch_angle = 8;
			torch_angle_step = 4;
			_root.createEmptyMovieClip("light",_root.getNextHighestDepth());
			anglel = -Math.atan2(tanksg._x - _root._xmouse, tanksg._y - _root._ymouse);
			light.clear();
			light.lineStyle(1,0xffffff,0);
			for (x = 0; x <= torch_angle; x += (torch_angle / torch_angle_step))
			{
				light.moveTo(this._x,this._y);
				ray_angle = anglel / (Math.PI / 180) - 90 - (torch_angle / 2) + x;
				ray_angle = ray_angle * (Math.PI / 180);
				for (y = 1; y <= torch_step; y++)
				{
					if (ground.hitTest(this._x + (torch_power / torch_step * y) * Math.cos(ray_angle), this._y + (torch_power / torch_step * y) * Math.sin(ray_angle), true) || enemy.hitTest(this._x + (torch_power / torch_step * y) * Math.cos(ray_angle), this._y + (torch_power / torch_step * y) * Math.sin(ray_angle), true))
					{
						break;
					}
				}
				light.lineTo(this._x + (torch_power / torch_step * y) * Math.cos(ray_angle),this._y + (torch_power / torch_step * y) * Math.sin(ray_angle));
			}
			mousex = _xmouse - this._x;
			mousey = (_ymouse - this._y) * -1;
			angle = Math.atan(mousey / mousex) / (Math.PI / 180);
			this._x = _root.player._x;
			this._y = _root.player._y - 17;
			if (mousex < 0)
			{
				angle += 180;
			}
			if (angle > 180)
			{
				angle = 180;
			}
			if (angle < 0)
			{
				angle = 0;
			}
			if (angle < 90)
			{
				this.cannonsg._yscale = 100;
			}
			else if (angle > 90)
			{
				this.cannonsg._yscale = -100;
			}
			firepower = 10000;
			this.cannonsg._rotation = angle * -1;
		};
		var isMouseDown:Boolean = false;
		var bulletReady:Boolean = true;
		var bulletDelay:Number = 1000;
		this.onMouseDown = function()
		{
			isMouseDown = true;
		};
		this.onMouseUp = function()
		{
			isMouseDown = false;
		};
		_root.onEnterFrame = function()
		{
			if (isMouseDown && bulletReady)
			{
				bulletReady = false;
				currentTime = getTimer();
				angle = tanksg.cannonsg._rotation - 1;
				start_ball_x = tanksg._x + 57 * Math.cos(angle * Math.PI / 180);
				start_ball_y = tanksg._y + 57 * Math.sin(angle * Math.PI / 180);
				cannonball_fired = _root.attachMovie("cannonball", "cannonball_" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
				cannonball_fired2 = _root.attachMovie("cannonball", "cannonball_" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
				cannonball_fired3 = _root.attachMovie("cannonball", "cannonball_" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
				cannonball_fired4 = _root.attachMovie("cannonball", "cannonball_" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
				cannonball_fired5 = _root.attachMovie("cannonball", "cannonball_" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
				cannonball_fired.dirx = Math.cos((angle - 6) * Math.PI / 180) * firepower;
				cannonball_fired.diry = Math.sin((angle - 6) * Math.PI / 180) * firepower;
				cannonball_fired2.dirx = Math.cos((angle - 3) * Math.PI / 180) * firepower;
				cannonball_fired2.diry = Math.sin((angle - 3) * Math.PI / 180) * firepower;
				cannonball_fired3.dirx = Math.cos(angle * Math.PI / 180) * firepower;
				cannonball_fired3.diry = Math.sin(angle * Math.PI / 180) * firepower;
				cannonball_fired4.dirx = Math.cos((angle + 3) * Math.PI / 180) * firepower;
				cannonball_fired4.diry = Math.sin((angle + 3) * Math.PI / 180) * firepower;
				cannonball_fired5.dirx = Math.cos((angle + 6) * Math.PI / 180) * firepower;
				cannonball_fired5.diry = Math.sin((angle + 6) * Math.PI / 180) * firepower;
				cannonball_fired.onEnterFrame = function()
				{
					this._x += this.dirx / 50;
					this._y += this.diry / 50;
					if ((_root.ground.hitTest(this._x, this._y, true)))
					{
						this.removeMovieClip();
					}
				};
				cannonball_fired2.onEnterFrame = function()
				{
					this._x += this.dirx / 50;
					this._y += this.diry / 50;
					if ((_root.ground.hitTest(this._x, this._y, true)))
					{
						this.removeMovieClip();
					}
				};
				cannonball_fired3.onEnterFrame = function()
				{
					this._x += this.dirx / 50;
					this._y += this.diry / 50;
					if ((_root.ground.hitTest(this._x, this._y, true)))
					{
						this.removeMovieClip();
					}
				};
				cannonball_fired4.onEnterFrame = function()
				{
					this._x += this.dirx / 50;
					this._y += this.diry / 50;
					if ((_root.ground.hitTest(this._x, this._y, true)))
					{
						this.removeMovieClip();
					}
				};
				cannonball_fired5.onEnterFrame = function()
				{
					this._x += this.dirx / 50;
					this._y += this.diry / 50;
					if ((_root.ground.hitTest(this._x, this._y, true)))
					{
						this.removeMovieClip();
					}
				};
				if (enemy.hitTest(tanksg._x + (torch_power / torch_step * y) * Math.cos(ray_angle), tanksg._y + (torch_power / torch_step * y) * Math.sin(ray_angle)))
				{
					enemy.swapDepths(_root.getNextHighestDepth());
					enemy.removeMovieClip();
				}
				tanksg.cannonsg.play();
			}
			else
			{
				if (currentTime + bulletDelay <= getTimer())
				{
					bulletReady = true;
				}
			}
		};
	}
	crosshair.onEnterFrame = function()
	{
		this._x = _xmouse;
		this._y = _ymouse;
		if (this._y > _root.ground._y)
		{
			this._y = _root.ground._y;
		}
	};

Cheers, Mrbloo2