Actionscript [Moving Movie Clips using Keyboard]
:: Lessons :: Advance Lessons
Page 1 of 1
Actionscript [Moving Movie Clips using Keyboard]
To capture Keyboard input, Actionscript uses the object "Key". This object listens to Keyboard events such as keydown, keyup, keypress and also returns keycode being pressed.
[putting the script on stage and movie clip's instance name is MC]
[putting the script on the movie clip itself ]
[putting the script on stage and movie clip's instance name is MC]
- Code:
MC.onEnterFrame = function(){
if (Key.isDown(Key.UP)){
MC._y-=1; // moves MC 1 pixel upward... y-axis
}
}
[putting the script on the movie clip itself ]
- Code:
onClipEvent(keyDown){ // keyDown event triggers when a key is pressed
if(Key.isDown(Key.UP)){
this._y-=1;// moves this movie clip 1 pixel upward... y-axis
}
}
Wingedge- Admin
-
Number of posts : 77
Age : 40
Name : Sir Francis
Year Level : Instructor
Location : UC
Registration date : 2008-06-10
Credits
GP: 9999
Similar topics
» Actionscript [Collision of 2 Movie Clips]
» Actionscript [Variable Declaration]
» Actionscript [Firing Projectiles]
» Actionscript [MC always faces the mouse]
» Actionscript [MC follows mouse and hiding mouse cursor]
» Actionscript [Variable Declaration]
» Actionscript [Firing Projectiles]
» Actionscript [MC always faces the mouse]
» Actionscript [MC follows mouse and hiding mouse cursor]
:: Lessons :: Advance Lessons
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum