Dear all,
I want to capture when arrow up and arrow down are pressed. The idea is while these keys are pressed I will move a movieClip. This is what I did:
stage.addEventListener(KeyboardEvent.KEY_UP,key_Up);
stage.addEventListener(KeyboardEvent.KEY_DOWN,key_Down);
stage.addEventListener(Event.ENTER_FRAME,mainLoop);
function key_Up(event:KeyboardEvent) {
keyPressed=-1;
}
function key_Down(event:KeyboardEvent) {
keyPressed = event.keyCode;
}
function mainLoop(event:Event) {
if (keyPressed ==38) {
trace("ArrowUp")
}
if (keyPressed==40) {
trace("ArrowDown")
}
}
Thanks in advance for feedback