Tutorials Home
What's New
Top Rated
Submit
myTutes
Random!
Essential Coding For Flash MX 2004 Games
Author: ElmStFreddie
Basic Movie Clip Movement
Create a movieclip, and then enter this in its coding:
onClipEvent(load){
moveSpeed=3;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x+=moveSpeed;
} else if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
}
if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}
}
3 as a move speed is fairly slow, feel free to change it. Also, this will not change the direction the movieclip is facing. If you want to change the way it faces for moving left and right (the movieclip should be facing right) you add this after onClipEvent(load){
xscale = _xscale;
And then after this._x+=moveSpeed (and this._x-=moveSpeed):
_xscale = -xscale;
| » Level Intermediate |
|
|
Added: : 2005-08-17
Rating: 7.20 Votes: 5
Hits: 795
|
| » Author |
|
Flash For Dummies
|
| » Download |
|
Download the files used in this tutorial.
|
|
Download (0 kb)
|
|
Get conversion and unzipping tools
for PC and Mac here!
|
| » Forums |
|
More help? Search our boards for quick answers!
|
|
Please rate this tutorial, 10 is the top rating, you can also click the
comments link to read/write a review.
|
|
|