下面的代码抛出错误 1046:未找到类型或不是编译时常量:KeyboardEvent。
有人知道为什么吗?
import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;
import flash.system.Capabilities;
import flash.system.System;
if (Capabilities.cpuArchitecture == "ARM")
{
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
}
function handleKeys(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.BACK)
{
NativeApplication.nativeApplication.exit();
}
}
答案 0 :(得分:3)
您需要导入KeyboardEvent类。
这是否有效(请注意我添加的其他导入语句):
import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;
import flash.system.Capabilities;
import flash.system.System;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
if (Capabilities.cpuArchitecture == "ARM")
{
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
}
function handleKeys(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.BACK)
{
NativeApplication.nativeApplication.exit();
}
}