Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Move an object on keypress

How do I move a graphic on keypress

on (keyPress "<Enter>") {

Move graphic left here

}



Thanks,
iamatramp
0
iamatramp
Asked:
iamatramp
  • 2
1 Solution
 
ddlamCommented:
1 Create a new movie clip(Ctrl+F9)
2 import or paste your graphic into the movie clip
3 drag your movie clip to stage and name your movie clip instance name as "picture" (Ctrl+F3)
4 add below into main timeline, frame 1

this.onEnterFrame = function(){
  if(Key.isDown(Key.ENTER)) {
    picture._x++;
  }
}
0
 
Gorba916Commented:
listenerObj = new Object();
listenerObj.onKeyDown = function()
{
      if (Key.getCode() == 13) {
            trace("You pressed Enter!");
            picture._x++;
      }
}
Key.addListener(listenerObj);
0
 
Gorba916Commented:
To make Enter and Backspace work make sure "disable keyboard shortcuts" is checked in the test move playback... Controls > disable keyboard shortcuts
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now