Actionscript 3: Detect the difference between a Mouse click and a Mouse drag.

How do you tell if the user clicked or dragged in your flash app? Take a look:

private var time:uint;

function onMouseDown(event:Event):void {
     time = getTimer();
     startDrag();
}

function onMouseUp(event:Event):void {
     var diff = getTimer() - time;
     if (diff < 250) {
           trace("clicked");
     }
     stopDrag();
}

This entry was posted in Actionscript 3.0 and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>