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.