Making Object Move Using Arrows
Start by naming layer 1 circle, this is the only layer that is required for this tutorial.
Using the Oval tool draw out a circle on the stage, convert it to a movie clip.
Now right click on the circle, and select actions.
Now on the first line type in:
onClipEvent (enterFrame) {
//if the left arrow is pressed, the circle will move to the left,
//the number determines how fast it will move.
if (Key.isDown(Key.LEFT)) {
this._x = _x-7;
} else if (Key.isDown(Key.RIGHT)) {
this._x = _x+7;
}
//the circle will move up
if (Key.isDown(Key.UP)) {
this._y = _y-7;
//the circle will move down
} else if (Key.isDown(Key.DOWN)) {
this._y = _y+7;
}
}
NOTE: you can quite easily copy paste these action, where I have explained what the actions will do won’t interfere as I have placed two forward slashes before them, this is so flash doesn’t pay any attention to them.
Well, how easy was that?
1 comment:
you just saved my project ! thank you soooo much !
Post a Comment