Simulate click event in AS3

Fran Verona picture Fran Verona · Sep 23, 2011 · Viewed 16.1k times · Source

Is there any way to simulate a click event in AS3? I'm trying this:

element.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN, true, false));

But click event isn't trigger it.

Answer

Pranav Hosangadi picture Pranav Hosangadi · Sep 23, 2011

If you are listening for MouseEvent.CLICK then dispatch MouseEvent.CLICK. You are now dispatching MouseEvent.MOUSE_DOWN

element.dispatchEvent(new MouseEvent(MouseEvent.CLICK));