LiTWol @ Oleg Terenchuk

  • Contact
  • Tips & Tricks
  • About me

User login

  • Request new password
To prevent automated spam submissions leave this field empty.

litwol's tweets

  • Youth is spent learning to turn our brain on producing results. No one bothers teaching us how to turn it off. Damn you insomnia — 2 years 17 weeks ago
  •  
  • 1 of 9
  • ››
more
Home

Playing with flash keyboard click events

Submitted by litwol on Sun, 01/17/2010 - 23:51

Incredibly simple flash app that demonstrates simple key controls.
Use key up, down, left, and right to control the grey rectangle.

For this code to work you are required to create a rectangle movie clip instance called 'rect_mc'.

Note to self: Learn how to create simple shapes programmatically.

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);

function keyDownHandler(event:KeyboardEvent): void {
if ( event.keyCode == Keyboard.LEFT ) {
rect_mc.x -= 5;
}
else if ( event.keyCode == Keyboard.UP) {
rect_mc.rotationX -= 5;
}
else if ( event.keyCode == Keyboard.RIGHT) {
rect_mc.x += 5;
}
else if ( event.keyCode == Keyboard.DOWN) {
rect_mc.rotationX +=5;
}
}

Tags:
  • ActionScript 3
  • CS4
  • Flash

LiTWoL © Oleg Terenchuk - Hosted on Linode.com 512