Space Shooter - Movie Clip and Movement
| Category | : Flash | Views | : 32449 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : space-shooter-movie-clip-and-movement.zip | ||
| Result | : See the result | ||||
| Index Series | Next >>> |
This tutorial is series of tutorials that will teach you how to create Space Shooter Game. The tutorial is divided in 5 parts. To see the complete tutorials, please see Space Shooter Flash Game
This is the first part of a series of Space Shooter tutorials. In this part we are going to learn the basics of Movie Clips and character movement.
First create a new document in Flash, click "File" > "New...", select "ActionScript 2.0" and click Ok.
Create a Movie Clip by right clicking your library tab and selecting "New Symbol...", make sure "Movie Clip" is selected and choose a name.

Flash will create and open the Movie Clip for editing, so just paste an image or draw a space ship with Flash's drawing tools.
After drawing your ship, get back to the main timeline by click on "Scene 1":

Now drag your Movie Clip from the library to the Stage, select it and give it an instance name.

I am going to name it "Ship". So "Ship" is how I am going to call this Movie Clip instance inside my code.
We just made our ship, so let's make it move.
Right click the first frame in your timeline and select "Actions". Type this:
this.onEnterFrame = function()
{
if (Key.isDown(Key.RIGHT))
{
Ship._x += 10;
} else if (Key.isDown(Key.LEFT))
{
Ship._x -= 10;
} else if (Key.isDown(Key.UP))
{
Ship._y -= 10;
} else if (Key.isDown(Key.DOWN))
{
Ship._y += 10;
}
}
Press Ctrl + Enter and test it, use the arrow key to move your ship around.
Here is how this code works:
this.onEnterFrame = function()
{
...
}
This is a very simple event from flash; the code inside it will be executed every time flash enters this frame.
if (Key.isDown(Key.RIGHT))
{
Ship._x += 10; //_x -= 10 would move the ship to the left.
}
This check if the right key is pressed, then move the Ship 10 pixels to the right.
else if (Key.isDown(Key.Up))
{
Ship._y -= 10; // _y += 10 would move the ship down.
}
If the up arrow key is pressed, the ship will move up.It's the same thing as before, but this time we added "else" before "if" because we don't want the ship to move in two directions at the same time.
In case you want the ship to move freely remove the "else" and try to move it.
We are done with movement! In the next tutorial we are going to make our ship fire bullets.
![]() |
![]() |
![]() |
![]() |
![]() |
| Index Series | Next >>> |
Supporters
Reseller Web HostingDo you need pc kids games that are affordable? If you are having a hard time finding Video Games that are kid friendly, make sure you do your research online before making a purchase. Whether you are looking for playstation 1 games or xbox games, the internet is a powerhouse of imformation that will keep you up to date on all of your video game needs!




