How can i “emulate” a MouseEvent, that has not been initiated by a button with a eventListener
(e.g. just by a simple function call) and how can i pass variables into it to switch the event.types?
public function myMouseEvent(event:MouseEvent):void
{
switch (event.type)
{
case "mouseDown" :
trace(event.type)
break;
case "mouseUp" :
trace(event.type)
break;
}
}
myMouseEvent(null) // ? nothing happens...
1/ Basic
In your case you can call directly
2/ Event
But you could do it in a more event-oriented manner.
where
eventDispatcheris the Sprite (or something else) you added your listener to.3/ Proper Event
Since your can’t access to all properties of the MouseEvent when you dispatch it like that, there is a cleaner way to do it:
All three may work!