Created
March 11, 2009 11:18
-
-
Save oleganza/77424 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* treat double click as a single click (hello, Mom! :-) | |
function onMouseDown(){ | |
if (!SingleClick()) return | |
... | |
} | |
*/ | |
package pierlis.framework | |
{ | |
public function SingleClick(delay = SC.DELAY) | |
{ | |
return SC.singleClick(delay) | |
} | |
} | |
import flash.utils.* | |
class SC | |
{ | |
static public const DELAY = 400 | |
static var secondClick = null | |
static var timeoutId = null | |
static public function clean() | |
{ | |
clearTimeout(timeoutId) | |
secondClick = false | |
} | |
static public function singleClick(delay = SC.DELAY) | |
{ | |
if (secondClick) | |
{ | |
clean() | |
return false | |
} | |
else | |
{ | |
clean() | |
timeoutId = setTimeout(clean, delay) | |
secondClick = true | |
return true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment