Move an object on keypress

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

on (keyPress "<Enter>") {

Move graphic left here


Question by:iamatramp
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

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)) {

Expert Comment

ID: 17239474
listenerObj = new Object();
listenerObj.onKeyDown = function()
      if (Key.getCode() == 13) {
            trace("You pressed Enter!");

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
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 live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

726 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