解决鼠标单双击冲突的问题

/*舞台上有个obj影片剪辑*/

import flash.events.MouseEvent;



var s:String;

var doubleClick:Boolean = false;



obj.doubleClickEnabled = true;

obj.addEventListener("click",image1_clickHandler);

obj.addEventListener("doubleClick",image1_doubleClickHandler);



function image1_clickHandler(e:MouseEvent):void

{

	s = e.type.toString();

	setTimeout(laterClickFunction,320,e);

}

//在320毫秒没到之前再次点击执行此函数

function image1_doubleClickHandler(e:MouseEvent):void

{

	s = e.type.toString();

}



function laterClickFunction(e:MouseEvent):void

{

	if (s == "doubleClick")

	{

		//双击执行这里

		trace("双击");

		if (! doubleClick)

		{

			doubleClick = true;

			e.target.scaleX = 2;

			e.target.scaleY = 2;

		}

		else

		{

			doubleClick = false;

			e.target.scaleX = 1;

			e.target.scaleY = 1;

		}

	}

	else if (s == "click")

	{

		//单击执行下面

		trace("单击");

	}

}

你可能感兴趣的:(问题)