Flash 4 scripting part 3 - using key events

 

the sample:

use your arrow keys to move the plane. you will have to click on the swf file first to activate it.

click here to download the fla file

the way to do it:

the aeroplane is a movieclip with the instance name "test".

for the action you need a button which can be invisible. the script for the button is as follows:

On (Key: <Right>)
  Set Property ("/test", X Position) = GetProperty ("/test",_x ) + 9
End On
On (Key: <Left>)
  Set Property ("/test", X Position) = GetProperty ("/test",_x ) - 9
End On
On (Key: <Up>)
  Set Property ("/test", Y Position) = GetProperty ("/test",_y ) - 9
End On
On (Key: <Down>)
  Set Property ("/test", Y Position) = GetProperty ("/test",_y ) + 9
End On

to enter the key event you simply select the onMouseEvent line and change it to KeyPress, click into the entry field and hit the key you want.

bg

 

 

 
1