Using MouseEvent.DOUBLE_CLICK in AS3

6 Comments 30 December 2010

Surprisingly I have never had a need to use the double click event in ActionScript 3.0 until this morning. I presumed it would work exactly like the single click event so at first I just used this:

item.addEventListener(MouseEvent.DOUBLE_CLICK, listener);

But nothing happened! A little look at the docs revealed why, you just need to add this line:

item.doubleClickEnabled = true;
item.addEventListener(MouseEvent.DOUBLE_CLICK, listener);

Simple.


Posted in ActionScript, Tip, Uncategorized

6 Responses to Using MouseEvent.DOUBLE_CLICK in AS3

  1. 14 April 2011

    This code run only adobe air..

  2. 14 April 2011
    FlashMonkey

    Hey Mahmut – nope it works for web apps too, see an example here. If you double click the screen the boxes fall to the bottom of the page.

  3. 14 September 2011

    ok I’m sorry

  4. 14 September 2011

    but you add —–item.doubleClickEnabled = true;—
    this is run now…
    thank you;

  5. 15 December 2011

    I think that if we have a dynamic TextField on the MovieClip/Button it won’t work! True?

  6. 19 December 2011
    FlashMonkey

    Hey Carlos, is .selectable set to true or false on your dynamic textfield? Might have something to do with that.

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>