Browsing Journal entries by Category "Actionscript"
Categories: Flash , Actionscript

so I needed to record a double click in flash for a project and went looking for code.

wow. there's a lot of convoluted and LONG code out there for such a simple thing! recording a double click shouldn't require 30 lines of code. if it does, you're doing something seriously wrong.

 

here's MY actionscript 2 (AS2) code for detecting a double click in flash if you want to change the speed at which you want to detect make 'double_click_wait' higher or lower. 11 lines of code is all you should need.

 

//mouse double click
var double_click_wait = 300;
var lastClick = 0;
var mouseListener:Object = new Object();
mouseListener.onMouseUp = function() {
	if ((getTimer()-previousClick) < double_click_wait) {
		trace("mouse double click ");
		previousClick = 0;
	}
	previousClick = getTimer();
};
Mouse.addListener(mouseListener);

 


Page 1 of 1