Next entry >>
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);

 
| Newest comments last| Back

Perfect...

Thanks!

Posted on Monday March 09, 2009 @ 02:30 pm

Add a Comment

Comments must first be APPROVED before they are publicly viewable.
*Name:
Email:
(Hidden)
url:
*Comments:
  Remember my details
*Verify:
 
Please type the verification string for security purposes.
(* Required).
Line breaks and paragraphs are automatically converted
All HTML tags will be removed.
Comment Preview
says:

Posted on Friday February 03, 2012 @ 09:26pm


Page 1 of 1