Adobe Air - 键盘事件错误
下面的代码抛出错误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();
}
}
The code below throws the error 1046: Type was not found or was not a compile-time constant: KeyboardEvent.
Does anybody know why?
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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要导入 KeyboardEvent 类。
这是否有效(请注意我添加的附加导入语句):
You need to import the KeyboardEvent class.
Does this work (Note the additional import statement I've added):