Flash Tutorial: Arrow Key Movement
1. Create a circle on the stage.
2. Select it and Convert it to a Movie Clip.
3. Open up it’s Actions and type in the following:
onClipEvent(load){ //Load this data
speed=5
}
onClipEvent(enterFrame){
if(Key.isDown(Key.LEFT)){//If the Left key is down
this._x-=speed //This object move whatever speed equals to the left
}
if(Key.isDown(Key.RIGHT)){ //This object move whatever speed equals to the right
this._x+=speed
}
if(Key.isDown(Key.UP)){ //This object move whatever speed equals up
this._y-=speed
}
if(Key.isDown(Key.DOWN)){ //This object move whatever speed equals down
this._y+=speed
}
}
Explanation: onClipEvent(load){ speed=5
This basically means “On the frame that this code is on, load this data.”
Explanation: onClipEvent(enterFrame){
This means “On every frame this code is on, the following shall take place.”
Explanation: this._##=speed
This means “This will move either Horizontally (X) or Vertically (Y) at the same rate as speed.”
Well there you have it!
1 Comment »
Leave a comment
-
Archives
- August 2008 (1)
- June 2008 (3)
-
Categories
-
RSS
Entries RSS
Comments RSS
asdasdawdasdasd