开发者

Actionscript 3.0: keyboard events and a remote presenter

开发者 https://www.devze.com 2022-12-17 08:26 出处:网络
I have a simple Flash movie with the following code. The idea is to move from one frame to the next or back using the arrow keys on the keyboard:

I have a simple Flash movie with the following code. The idea is to move from one frame to the next or back using the arrow keys on the keyboard:

stop();

//listen for key press
stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);

//if left or right arrow, go to previous or next frame
function myKeyDown(e:KeyboardEvent):void {

switch (e.keyCode) {
case Keybo开发者_运维技巧ard.LEFT :
prevFrame();
break;

case Keyboard.RIGHT :
nextFrame();
break;
}
}

So, this works fine, except that I need to use a Kensington Presenter to control the keyboard remotely. It should be sending a keydown command to the computer for either the right or left arrow keys, but it does not work.

It does work on a legacy Director project I have, using a similar syntax. Also works in PowerPoint.

Any thoughts would be appreciated. I'm working on a Mac, but the movie will run on Windows and Mac platforms as a compiled application.


If it doesn't throw an error, you must focus stage and write below event listener

stage.focus = this;
stage.focusRect = false;

stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);


function myKeyDown(e:KeyboardEvent):void {

switch (e.keyCode) {

case Keyboard.LEFT :

this.currentFrame++;

break;

case Keyboard.RIGHT :

this.currentFrame--;

break;
}

}
0

精彩评论

暂无评论...
验证码 换一张
取 消