as3 flash - 使用向上箭头的投影仪

时间:2015-06-05 16:32:06

标签: actionscript-3 flash

我正在使用flash cc并且知道如何在as2中执行以下操作但不是as3。

代码是什么,所以我可以使用键盘命令向上和向下箭头在时间轴中向前和向后移动到下一帧。这是用于mac和win投影机文件吗?

1 个答案:

答案 0 :(得分:0)

以下是在AS3中捕获键输入的示例:

import flash.ui.Keyboard;
import flash.events.KeyboardEvent;

//add the a key listener to the stage,  OR if using AIR you could add it to NativeApplication.nativeApplication to be truly global.
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

function keyDownHandler(event:KeyboardEvent):void {
    switch(event.keyCode) {
        case Keyboard.RIGHT:
        case Keyboard.UP:
        case Keyboard.PAGE_UP:
            //up or right or pageup was pressed
            nextFrame();
            break;

        case Keyboard.DOWN:
        case Keyboard.LEFT:
        case Keyboard.PAGE_DOWN:
            //down or left or pagedown was pressed
            prevFrame();
            break;
    }
}