Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.ui.Keyboard;
- import flash.events.KeyboardEvent;
- import flash.events.Event;
- public class KeyboardManager {
- var keyArray:Array = new Array();
- var i:Number;
- public function KeyboardManager(stageClip) {
- // constructor code
- stageClip.addEventListener(KeyboardEvent.KEY_DOWN,kDown)
- stageClip.addEventListener(KeyboardEvent.KEY_UP,kUp)
- for (i=0; i<222; i++) {
- keyArray.push([i,false]);
- }
- }
- function kDown(event:KeyboardEvent) {
- keyArray[event.keyCode][1]=true;
- }
- function kUp(event:KeyboardEvent) {
- keyArray[event.keyCode][1]=false;
- }
- public function isKeyDown(key) {
- return keyArray[key][1];
- }
- }
- }
- /* designed to work like as2's key.isDown(x) function.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement