Skip to main content
April 8, 2009
Question

What is the difference between MouseEvent.MOUSE_UP and MouseEvent.CLICK?

  • April 8, 2009
  • 2 replies
  • 2678 views
What is the difference between MouseEvent.MOUSE_UP and MouseEvent.CLICK?

Why should I use one of these over the other?

Code:
myButton_btn.addEventListener(MouseEvent.MOUSE_UP, fNavigate, false, 0, true);

myButton_btn.addEventListener(MouseEvent.CLICK, fNavigate, false, 0, true);
This topic has been closed for replies.

2 replies

April 8, 2009

Thanks!

I only read the specific MouseEvent pages... little did I know I should've been reading the InteractiveObject help pages.

Flash's help system has become truly awful.

At least in previous versions, if you knew what to type in the "Search" field you would find what you were looking for with examples on how to use it. Now, even with the proper search term, all you'll get is a bunch of keyword definitions and very few practical examples.

Inspiring
April 8, 2009

click is a more specific event: 'click' represents a mouseDown followed by a mouseUp for the same target object:

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html#event:click

excerpt for the click event:

"Dispatched when a user presses and releases the main button of the user's   pointing device over the same InteractiveObject. For a click event to occur, it must always follow this series of   events in the order of occurrence: mouseDown event, then mouseUp. The target object   must be identical for both of these events; otherwise the click event does not   occur. Any number of other mouse events can occur at any time between the   mouseDown or mouseUp events; the click event   still occurs."

This means you can mouseDown on an object, hold the mouse down, mouse Out, mouse Over again and then mouse Up at which point a click event will happen (for example)

Inspiring
April 8, 2009

Likewise, for mouseUp, it can happen if you mouseDown outside your target and then mouseOver your target with the button held down, releasing the button over your target (but in this case a valid 'click' has not occurred, because you never initiated the sequence by doing a mouseDown on the target).

For most cases, MouseEvent.CLICK is probably preferable.