当前位置: 代码迷 >> Web前端 >> AS3生成独自“双击事件”
  详细解决方案

AS3生成独自“双击事件”

热度:88   发布时间:2012-11-05 09:35:12.0
AS3生成单独“双击事件”

?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("单击")
?}?
}
本文转自:http://www.5uflash.com/flashjiaocheng/Fmsjiaocheng/1971.html
  相关解决方案