Is it possible for me to create a button that must be clicked 4 times within 3 seconds to call a function? How would i go about this?
Thanks, Troy.
Printable View
Is it possible for me to create a button that must be clicked 4 times within 3 seconds to call a function? How would i go about this?
Thanks, Troy.
there are many different ways you could do this. here's one:
PHP Code:button.addEventListener(MouseEvent.CLICK, quadClick, false, 0, true);
var clickCount:uint = 0;
var timer:Timer = new Timer(3000);
timer.addEventListener(TimerEvent.TIMER, stopQuadClick, false, 0, true);
function stopQuadClick(event:TimerEvent):void{
button.removeEventListener(MouseEvent.CLICK, countClicks);
button.addEventListener(MouseEvent.CLICK, quadClick, false, 0, true);
timer.stop();
}
function quadClick(event:MouseEvent):void{
clickCount = 0;
timer.start();
button.removeEventListener(MouseEvent.CLICK, quadClick);
button.addEventListener(MouseEvent.CLICK, countClicks, false, 0, true);
}
function countClicks(event:MouseEvent):void{
clickCount++;
if(clickCount == 3){
trace("clicked 4 times in 3 seconds");
stopQuadClick(null);
}
}
thank you very much Moagrius! Works great!
:thumbsup: