Ok, I know this is some old stuff which most of you probably already
knows but I am posting it cause I see funny codes to detect a double
click using onEnterframes and setInterval, etc. All you need is the
code below to detect a double click in Flash. To prevent stuff like
"triple click", just modify the code to execute
var pressCount:Number = 0;
var lastTime:Number = 0;
function onPress()
{
var now:Number = getTimer();
pressCount++
if((now - lastTime) < 300 && pressCount==2)
{
//Double click occurs, implement the code
pressCount = 0;
}
else if(pressCount == 2)
{
pressCount = 1;
}
lastTime = now;
}
We have to keep track of pressCount to prevent 'triple-clicking'. If you don't need to prevent that, just use
function onPress()
{
var now:Number = getTimer();
if((now - lastTime) < 300)
{
//Double click occurs, implement the code
//Triple Click will detect as 2 double click!
}
lastTime = now;
}
Do comment if anything is wrong! =)