Behold this example:
addEventListener("myEventType", myFunction("argument"));
function myFunction(args:String):Function {
return function(evt:Event):void {
trace(evt.currentTarget, "has", args);
};
}
dispatchEvent(new Event("myEventType", true));
It works.
Can I do something similar, but passing "argument"
through dispatchEvent()
?
It'd be very handy in a situation where dispatchEvent()
is in a wholly separated class from addEventListener()
and myFunction()
.
I'll be needing this a lot, so I want to do it without creating a custom event class for every situation.