Moving an object using the arrow key in Adobe Flash 8 |
| Written by AnaS | |
|
1. Create a new Flash8 document with 400x300 dimensions. Save it as flash8keys.fla. 4. Select the smiley picture and choose Modify>>Convert to Symbol (F8). In the Convert to Symbol window choose MovieClip as Type, asuure that registration point is center and give it smileyMC name. Now go in the Properties panel and give it an instance name of smiley_mc. 5. In the first frame of the actions layer choose Window>>Actions (F9) and insert the ActionScript code below:
var KeyListener:Object = new Object(); 6. Now let's see what the previous ActionScript code do. First we create a Flash listener object to listen the onKeyDown event. onKeyDown() event handler is invoked when a keyboard key is pressed.
If a key is pressed we analize if one of the LEFT, RIGHT, UP or DOWN key is pressed.
if(Key.isDown(Key.UP)){ 7. Test the movie (Ctrl+Enter) now. Hope this flash tutorial helps you! You need to Register in order to download the FLA file.
written by bruce montford , September 19, 2007
ikeep getting this error message when i test my movie 1046: Type was not found or was not a compile-time constant: Void.
written by AnaSt , September 19, 2007
In this tutorial it is used Flash 8 and ActionScript 2. What do you use?
written by coz , November 20, 2007
this really helped me - thanks very much
written by lil lee , December 11, 2007
it dont work
written by Toon , June 14, 2008
it won't work Scene=Scene 1, Layer=actions, Frame=1: Line 2: '{' expected KeyListener.onKeyDown = function():Void { Do you need more help? Ask now!
|
|
| Last Updated ( Friday, 28 March 2008 ) |