Flashadvisor logo
:: Desktop Shortcut
:: Flash Help
Advices from Experts

 Submit Here! · Link to Us · Newsletter · Tell a Friend ·

      Add Tutorial |

 

Advertise here










 

Google

Search WWW   
FlashAdvisor.com

 Home > Tutorials  > Beginners

Moving shapes or objects using keyboard in Flash MX 2004.

Author: Oleg Lazarenko | Email
Website : www.metamorphozis.com


Advertisement


You need a flash program where user will be able to move objects or shapes using keyboard? It’s not difficult to create. Just follow step-by-step instructions, write some action script code and you will make it!.

1. Launch Flash MX 2004

2. Create new Flash file. Click File > New...



3. Select Flash Document in a new window



4. With the "Rectangle Tool" draw a simple shape in the middle of the working area



5. Convert this shape to the movie clip



6. Click on the movie clip to select it and in the action script panel add the following code:


onClipEvent (load) {
moveit = 10;
}
onClipEvent (enterFrame) {
if ((Key.isDown(Key.RIGHT))) {
this._x += moveit;
} else if ((Key.isDown(Key.LEFT))) {
this._x -= moveit;
}
if ((Key.isDown(Key.DOWN))) {
this._y += moveit;
} else if ((Key.isDown(Key.UP))) {
this._y -= moveit;
}
}


7. Press Ctrl+Enter and enjoy the show:-) Now you can control the shape motion with the keyboard strokes. Just press "Up", "Down", "Right: or "Left" arrows. This code can be implemented to any game or flash movie.


Download Source File

| 1 |

Rate This Tutorial :
We hope the information helped you. If you have any questions or comments, please don't hesitate to post them on the Forums section
Submit your Tutorial at Click Here
  

Home | About Us | Contact Us | Feedback | Advertise with us

Best viewed in 800x600 resolution with Internet Explorer.

Site Developed and Hosted by  ethicsolutions.com
All rights reserved with FlashAdvisor

Flash is a registered trademark of Adobe Systems, Inc.

29 users online