How to control an movie Clip in Flash

By sora120592

control an movie Clip in Flash control an movie Clip in Flash

Rate: (5 Ratings)

this is a short tutorial on how to make a movie Clip move when you press a key. this Action script is used in a lot of popular flash games. later i will be adding how to make instant power-ups, health and enemies

Instructions

Difficulty: Moderate

Things You’ll Need:

  • Adobe Flash CS 3.
  • the will to learn.

Step1
first open up Adobe Flash
and start a new document.
make sure you choose Action script 2.
Step2
now make a object you want
to move.
Step3
now select it, right click
and press "convert to symbol...".
Step4
now mark the circle called "movie clip"
and call it what ever you like.
Step5
now that you have made the
movie clip right click on
it and select "Actions".
Step6
a little box will pop-up
click it and type in
A):
onClipEvent (load) {
walkSpeed = 10;
}

onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= walkSpeed;
}
if (Key.isDown(Key.RIGHT)) {
_x += walkSpeed;
}
if (Key.isDown(Key.DOWN)) {
_y += walkSpeed;
}
if (Key.isDown(Key.UP)) {
_y -= walkSpeed;

}
}
Step7
or B)
warning this is a bit more advanced and is an edit.
call your object an instance name and then go to the first frame in you flash document and type in:
this.[object instance name].onLoad = function () {
walkSpeed = 10;
}

this.[object instance name].onEnterFrame= function () {
if (Key.isDown(Key.LEFT)) {
_x -= walkSpeed;
}
if (Key.isDown(Key.RIGHT)) {
_x += walkSpeed;
}
if (Key.isDown(Key.DOWN)) {
_y += walkSpeed;
}
if (Key.isDown(Key.UP)) {
_y -= walkSpeed;

}
}
Step8
select "control>Test Movie"
and play around with your game.

Tips & Warnings

  • play around with these actions to get familiar with them.
  • you can always double click your movie clip to change the graphic.
  • check in often I'll update soon.
  • actions script is "Capital letter" sensitive so make sure the right letters are upper case the right places.

Post a Comment

POST A COMMENT

Request a New How-To Article

Looking for more How To information? Chances are there’s an eHow member who knows how to do what you’re looking to do. Submit an article request now!

eHow Article:  How to control an movie Clip in Flash

eHow Member: sora120592

sora120592

Enthusiast Enthusiast | 490 Points

Category: Computers

Articles: See my other articles

Related Ads