Sunday, October 24, 2010

Double clicking in AS3

Today we will learn how to listen for double clicking event.

Here's an example:

What we see is pretty simple to create. A button has a property called doubleClickEnabled - by default it is set to false, but we want to enable it:

myButton.doubleClickEnabled = true;

Now we can add a listener for the MouseEvent.DOUBLE_CLICK event.

myButton.addEventListener(MouseEvent.DOUBLE_CLICK, myFunction);

This can be used in applications (opening a directory, perhaps) and games (unit selection, attack, move to, etc.).

Keep in mind that the time interval between the clicks that counts as double click is set manually in each user's system options - we aren't able to modify that. But if you really want to, you'll need to make a custom class for double clicking. More on that tomorrow!

Thanks for reading!


Creating a custom double click function in AS3

No comments:

Post a Comment