Blog of X. Ding

Actionscript 3: Double Click issues

Posted in Actionscript 3 by xding78 on July 27, 2010

It’s already tricky that in Actionscript 3, an object can only listen to double click events when it’s double-click enabled. When an object has many interactive child objects things can go really ugly. Apparently the designers of Actionscript 3 seriously dislike double-click. As a result, everyone using Actionscript 3 implementing double click action is punished by very obscure coding.

It’s not just so simple as adding:

obj.doubleClickedEnabled = true;

The actual problem is that often in an (interactive) object there are many other (interactive) objects. And a MouseEvent works like that: The target of the MouseEvent is the one that the mouse is directly hovering. So it’s often happened that the target of the MouseEvent is a Child of (a Child of a Child…) the object you want the MouseEvent to target. If all the children in the object does not have any interaction, one very handy line could make life much easier:

obj.mouseChildren = false;

However, if an object (that contains interactive children which also needs to listen to MouseEvents) needs to listen to Double Click event that’s where things get uglier. You cannot use mouseChildren = false because that will prevent all child objects from listening to any MouseEvents.

And If the child that the mouse is hovering is not enabled for double click, the MouseEvent.DOUBLE_CLICK would never be registered. Hence, the end of the action chain.

So, in order for the parent object to get the MouseEvent.DOUBLE_CLICK event, all visible child objects have to be double click enabled.

So if MouseEvent.DOUBLE_CLICK doesn’t work, first check if all the child objects are enabled for double click.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: