CGArt-中国CGer中的绿色家园
首页 信息动态 原创排行 互动教程 资源千寻 CG人才 CGArt杂志 艺术设计 CG画廊 CG论坛 酷站欣赏 CG搜索 会员中心
Flash AS3生成单独“双击事件”
来源:闪吧 作者:net虫 编辑:浪漫的季节 发布时间:2007年09月26日 16:46:25

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("单击")
 } 
}
共有评论0条
更多评论..
作者信息 详细信息
评论人:
验证码:
内容:
 
about us advertisement publish conformity service cooperate associate link site map contact us help jump to the top of page