Fire Weapons with Key.addListener

Move The Laser Beams

Now we need to get each of those laser beams moving. Create a new function called moveLaser:

We're going to have multiple laser beams flying around the Stage, so we'll need to create a for loop. We'll use the standard n variable, and loop for the number of laser beams (lCount) plus one:

Great, now we'll create a laser MovieClip object we can target:

Let's move laser five pixels horizontally:

Now down in our onEnterFrame function we'll add a statement that calls moveLaser:

Test it:

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

Get Adobe Flash player