Simulate click event in AS3

Is there a way to simulate a click event in AS3? I try this:

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

But the click event does not fire it.

+5
source share
3 answers

If you are listening MouseEvent.CLICK, send it MouseEvent.CLICK. Now you sendMouseEvent.MOUSE_DOWN

element.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
+20
source

You must send a MouseEvent.CLICK event.

element.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false));
+3
source

To simulate a CLICK event, you must first send:

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

and then:

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

In the MOUSE_UP event, the handler then throws a click event (if the mouse is on top of the element, so you may need to set the mouse_x and mouse_y variables in the dispatched event.

0
source

All Articles