[AS3]as3鼠标动作DBClick双击类,双击单击类写法
在次转载一个网友写的鼠标双击类,DBClick.as.以下内容为程序代码,as3鼠标动作DBClick双击类,双击单击类写法
在次转载一个网友写的鼠标双击类,DBClick.as.以下内容为程序代码:
- import mx.utils.Delegate;
- import mx.core.UIObject;
- class DBClick {
- public static var DELAY_TIME:Number = 200;
- private var _mc:UIObject;
- private var intervalID:Number;
- private var delayTime:Number;
- public function DBClick(mc:UIObject) {
- _mc = mc;
- _mc.onMouseUp = Delegate.create(this, onClick);
- }
- private function onClick() {
- if (!delayTime) {
- delayTime = getTimer();
- if (intervalID != undefined) {
- clearInterval(intervalID);
- }
- intervalID = setInterval(this, "run", DELAY_TIME);
- } else {
- if ((getTimer()-delayTime)<DELAY_TIME) {
- _mc.dispatchEvent({target:_mc, type:'onDClick'});
- }
- delayTime = null;
- }
- }
- private function run():Void {
- if (delayTime) {
- _mc.dispatchEvent({target:_mc, type:'onClick'});
- delayTime = null;
- clearInterval(intervalID);
- }
- }
- public static function init(mc:UIObject) {
- var dClick = new DBClick(mc);
- }
- }
as3鼠标动作DBClick双击类,双击单击类写法示例
- import DBClick;
- DBClick.init(_btn);
- _btn.addEventListener("onDClick", this);
- _btn.addEventListener("onClick", this);
- function onDClick()
- {
- _btn.label="酷播提示CuPlayer.com,你刚才双击了我"
- }
- function onClick()
- {
- _btn.label="酷播提示CuPlayer.com,你刚才单击了我"
- }
热门文章推荐
- [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示例
请稍候...