Skip to content

Instantly share code, notes, and snippets.

@oleganza
Created March 11, 2009 11:18
Show Gist options
  • Save oleganza/77424 to your computer and use it in GitHub Desktop.
Save oleganza/77424 to your computer and use it in GitHub Desktop.
/* 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