I have run into a problem attempting to redispatch mouse events in ActionScript 3, which I am admittedly a bit incredulous about. I have narrowed it down to the MouseEvent.clone() method appearing, well, completely broken. The following event handler:
private function handleMouseMove( evt : MouseEvent ) : void
{
trace("mousemove", evt.stageX, evt.stageY);
var newEvt : MouseEvent = evt.clone() as MouseEvent;
trace("mousemoveclone", newEvt.stageX, newEvt.stageY);
}
Results in the following output, ad infinitum:
mousemove 167 206
mousemoveclone 0 0
This matches what the code I was redispatching the MouseEvent to was receiving, hence my hypothesis of the broken clone function.
This is directly contradictory to what the linked documentation indicates should happen, unless I have missed something. I am at an entire loss as to what I did (or did not do) that could possibly cause this behavior. Did the AS3 guys really forget to read their own documents on Event.clone()?
I can work around this by instead using function objects for my specific use case, but I'd prefer not to. Any ideas?
Edit: The localX and localY members are being properly cloned it seems, which puts me at even more of a loss as to what is going on here.
Thats a known bug. You can see the bug report here: http://bugs.adobe.com/jira/browse/FP-343
Everything else should get cloned though. You can always just assign stageX and stageY manually until the bug is fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With