[Flash]Move a MovieClip using arrow keys.

satheesh

New Member
Messages
883
Reaction score
0
Points
0
[Flash]Move a MovieClip using arrow keys.
  • Create a Movie Clip and Create a Rectangle or your design in the Movie Clip.
  • Come Back to Scene 1.
  • Select the Movie Clip and set them instance name = “movie”.
  • Select the first Frame.
  • Press F9 and Copy Code Below and paste it.
Code:
setInterval(function () {
              if (Key.isDown(Key.RIGHT)) {
                          setDirection(0);
                          _root.movie._x += 3;
              }
              if (Key.isDown(Key.LEFT)) {
                          setDirection(1);
                          _root.movie._x -= 3;
              }
              if (Key.isDown(Key.DOWN)) {
                          _root.movie._y += 3;
              }
              if (Key.isDown(Key.UP)) {
                          _root.movie._y -= 3;
              }
              updateAfterEvent();
  }, 10);
Good Luck.

Example:http://svprm.x10hosting.com/for_forums/move.swf
 
Last edited:
Top