- Home
- Tutorials
- Flash
- Intermediate
- Game with laser
Game with laser

Page 1 of 1
Johan Jansen
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
View all articles by Johan JansenWritten by: Johan Jansen [Sky_Doq]
Difficulty Level: intermediate
There is a FLA file for this tutorial. Your going to create something like this :
Make 3 layers
1: button ( move it below all other layers )
2: ship
3: laser
Ship
Now draw a ship and convet it to a movieclip ( MC ) call it ship so it can be targetted from the main timeline. In the first frame of the MC as frame action : drag movieclip leave target blank so the ship will be dragged,and now to get it under your mouse, Lock to mouse center.

Laser
Draw something that you want to shoot convert it into a MC call it laser and move it out of your sight.
Make two frames in the first frame action you move the laser by decreasing its y with 5 or something like this
GetProperty("",_y) - 5
If the y is below zero we don't need this MC anymore, so use this satement to destroy it
If GetProperty("",_y) < 0 remove MC

"" = targets this MC
in the next frame enter the same actions and goto and play 1
Button
Draw a rectangle which covers the whole playfield, convert it to a button.
In the button move the drawing from frame "up" to frame "hit" so it will be invisible, you get something like this:
Now in the mainframe of your fla-file edit the buttons actions ( on press )
The laser must be shot from the x and y of the ship, do this by using GetProperty target = ship
Put the x and y into a variable called 'ship_x' and 'ship_y'
Now to create a laser use duplicate MC to make a laser,
because depths can't be the same, your laser will be destroye if it's the same.
Make a variable 'n' let it increase with one, n = n+1 ( expression )
now duplicate the laser and call it laser&n ( expression ) below this, set its x and y right,
with Set Property ( x, ) target = laser&n ( expression ) value = ship_x do the same for the y
and set a "stop" action in the main timeline
If something is not clear to you , you can download the source-file and check it out, or mail me your question: sky_doq@hotmail.com

