[AS3]as3.0键盘侦听源代码示例
[AS3]as3.0键盘侦听源代码示例,键盘的点击与弹起,按键状态的确认,键盘的KeyCode表示
键盘的点击与弹起:
- //Source:
- stage.addEventListener(KeyboardEvent.KEY_DOWN, xKeyDown);
- stage.addEventListener(KeyboardEvent.KEY_UP, xKeyUp);
- function xKeyDown(event:KeyboardEvent):void{
- kb.text = "CuPlayer提示:点击"+event.keyCode;
- };
- function xKeyUp(event:KeyboardEvent):void{
- kb.text = "CuPlayer提示:弹起"+event.keyCode;
- };
按键状态的确认:
- var space_flag:Boolean = false;
- stage.addEventListener(KeyboardEvent.KEY_DOWN,xKeyDown);
- stage.addEventListener(KeyboardEvent.KEY_UP,xKeyUp);
- stage.addEventListener(Event.ENTER_FRAME,xEnterFrame);
- function xKeyDown(evt:KeyboardEvent):void{
- if(evt.keyCode == Keyboard.SPACE){
- space_flag = true;
- }
- }
- function xKeyUp(evt:KeyboardEvent):void{
- if(evt.keyCode == Keyboard.SPACE){
- space_flag = false;
- }
- }
- function xEnterFrame(evt:Event):void{
- if(space_flag){
- mc.gotoAndStop(2);
- }else{
- mc.gotoAndStop(1);
- }
- }
键盘的KeyCode表示:
- stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDown);
- function KeyDown(evt:KeyboardEvent){
- code_text.text = String(evt.keyCode);
- location_text.text = String(evt.keyLocation);
- ctrl_text.text = String(evt.ctrlKey);
- shift_text.text = String(evt.shiftKey);
- alt_text.text = String(evt.altKey);
- }
[AS3]as3.0键盘侦听源代码示例.
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...