Fire Weapons with Key.addListener

Remove the Laser Beams

Each of those laser beams will keep crawling off into infinity, which will start to bog down the processor. Let's remove them when they leave the stage. Create an if statement that checks to see if the X position is greater than sW:

Run a removeMovieClip statement when the condition is true:

While we're working with the moveLaser function, let's get that "5" out of there and replace it with a variable called lSpeed:

OK, back to the top of the markup where we need to declare the sW and lSpeed variables. I decided to make lSpeed 20 instead of 5:

Check it:

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player