简体   繁体   English

使用ActionScript 3的键盘输入

[英]Keyboard input using ActionScript 3

I am learning how to use Flash using CS4, and focusing mainly on ActionScript3 (since I come from a coding background and not a designer background). 我正在学习如何使用CS4来使用Flash,并且主要关注ActionScript3(因为我来自编码背景而不是设计师背景)。

I want to respond to the user pressing keys on the keyboard. 我想回应用户按下键盘上的键。

I have used the official example source at the Flash reference site and followed the CS4 instructions for classes. 我已经在Flash参考站点上使用了官方示例源,并按照CS4的说明进行了学习。 However, all it responds to is special keys like ctrl and shift, for these keys it works fine. 但是,它只响应ctrl和shift之类的特殊键,因为这些键可以正常工作。 For keys like a,b,c there is no response whatsoever. 对于a,b,c之类的键,没有任何响应。 Am I doing something wrong? 难道我做错了什么? Is there some setting I need to change? 我需要更改某些设置吗? Maybe I need to change something outside my ActionScript (like a project setting maybe). 也许我需要在ActionScript之外进行一些更改(例如,可能需要进行项目设置)。 Any help would be greatly appreciated. 任何帮助将不胜感激。

A quite usual problem is that the Flash IDE shortcut keys won't respond (as they are used by the IDE). 一个很常见的问题是Flash IDE快捷键不响应(因为IDE使用了快捷键)。 Make sure you also test your movie in a browser or in the standalone player. 确保您还在浏览器或独立播放器中测试电影。

Are you running it in full screen mode? 您是否在全屏模式下运行它? You can't hear those keys if you are. 如果您听不到这些键。 (Security restriction) (安全限制)

The up and down handlers trap different kinds of keys: 上下处理程序会捕获不同种类的键:

KeyboardEvent.KEY_DOWN gets keyslike backspace and delete, while KeyboardEvent.KEY_UP gets the usual az suspects. KeyboardEvent.KEY_DOWN获取诸如退格键和删除键之类的键,而KeyboardEvent.KEY_UP获得常见的az可疑字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM