📄 doubleclick.as
字号:
/*
解决鼠标单击双击重复执行的分装类
时间:07-12-10
import Charlotte.DBClick;
but.doubleClickEnabled=true;
new DBClick(but);
but.addEventListener(MouseEvent.CLICK,SClick);
but.addEventListener(MouseEvent.DOUBLE_CLICK,DClick);
function SClick(evt:MouseEvent){
trace("SClick");
}
function DClick(evt:MouseEvent){
trace("DClick");
}
*/
package com.dmh2002.util{
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.utils.setTimeout;
import flash.utils.clearTimeout;
//
public class DoubleClick {
private var __target:DisplayObject;
private var interval:uint;
public function DoubleClick(_target:DisplayObject):void {
__target = _target;
__target.addEventListener(MouseEvent.CLICK,h_Stop_SClick,false,100);
__target.addEventListener(MouseEvent.DOUBLE_CLICK,h_DClick);
__target.addEventListener(Event.REMOVED_FROM_STAGE,clear);
}
private function h_Stop_SClick(evt:MouseEvent):void {
evt.stopImmediatePropagation();
clearTimeout(interval);
interval = setTimeout(h_Send_SClick,260);
}
private function h_Send_SClick():void {
clearTimeout(interval);
__target.removeEventListener(MouseEvent.CLICK,h_Stop_SClick);
__target.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
__target.addEventListener(MouseEvent.CLICK,h_Stop_SClick,false,100);
}
private function h_DClick(evt:MouseEvent):void {
clearTimeout(interval);
}
public function clear(evrt:Event=null):void {
clearTimeout(interval);
__target.removeEventListener(MouseEvent.CLICK,h_Stop_SClick);
__target.removeEventListener(MouseEvent.DOUBLE_CLICK,h_DClick);
__target.removeEventListener(Event.REMOVED_FROM_STAGE,clear);
__target = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -