---
title: "as3 双击事件"
author: "wdbk123"
date: "2011-09-02T17:50:33Z"
tags: []
categories: ["Web前端"]
slug: "as3"
draft: false
lastmod: "2011-09-02T17:50:33Z"
id: 1164572
url: "https://wdbk123.iteye.com/blog/1164572"
---

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