Solved

Move an object on keypress

Posted on 2006-07-06
5
328 Views
Last Modified: 2008-03-17
How do I move a graphic on keypress

on (keyPress "<Enter>") {

Move graphic left here

}



Thanks,
iamatramp
0
Comment
Question by:iamatramp
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
ddlam earned 50 total points
ID: 17056572
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
 

Expert Comment

by:Gorba916
ID: 17239474
listenerObj = new Object();
listenerObj.onKeyDown = function()
{
      if (Key.getCode() == 13) {
            trace("You pressed Enter!");
            picture._x++;
      }
}
Key.addListener(listenerObj);
0
 

Expert Comment

by:Gorba916
ID: 17239479
To make Enter and Backspace work make sure "disable keyboard shortcuts" is checked in the test move playback... Controls > disable keyboard shortcuts
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question