|
AS3虽然提供了双击事件,但在触发双击事件之前会触发一个单击事件,这给编写游戏的朋友带来了很多不便,于是还是自己再加入写判断来生成单一的事件,也就是有双击事件的时候就没有单击事件,有单击事件的时候就没有双击事件。代码如下:
mc.doubleClickEnabled=true mc.addEventListener(MouseEvent.CLICK,chick) mc.addEventListener(MouseEvent.DOUBLE_CLICK,double) var sta=false function double(e){ sta=true } function chick(e){ sta=false var time=new Timer(260,1) time.start() time.addEventListener(TimerEvent.TIMER,func) } function func(e){ if(sta){ trace("双击") }else{ trace("单击") } } |