LiTWol @ Oleg Terenchuk

  • Contact
  • About me

User login

What is OpenID?
To prevent automated spam submissions leave this field empty.
  • Log in using OpenID
  • Cancel OpenID login
  • Request new password

litwol's tweets

  • Life is one large balancing act. In fact, we all work for a large circus. The funny thing is most just don't get paid for it. — 47 weeks 5 days 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;
}
}

  • 3292 reads
Tags:
  • ActionScript 3
  • CS4
  • Flash

Recent posts

  • Developing PHP in VIM - VIM IDE for PHP
  • Creating custom fields using Drupal 7 field api
  • Creating 3d cube movieClip using Sprites and animating rotation through ActionsScript 3.0
  • Adding sprite from inside an external class onto stage and animating it using arrow key movement.
  • Playing with flash keyboard click events
  • Script to benchmark API execution time.
  • Very good dvcs guide
  • High throughput web architecture with drupal - *For authenticated users*
  • About me - Oleg Terenchuk
  • Note to self
  • Pre-generating drupal forms
  • Change memcached admin stats page
  • The cult of done

LiTWoL © Oleg Terenchuk - Hosted on Linode.com 512