Expected / pseudo example:
stage.addEventListener(MouseEvent.CLICK, onClick.someWayToPassParameters(true, 123, 4.56, "string"));
function onClick(e:
I would modify Creynders example slightly:
protected function createHandler(handler:Function, ...args):Function
{
var h:Function = function(e:Event = null):void
{
trace(args);
if (handler != null)
handler(e);
}
return h;
}
sm.addEventListener(StyleEvent.STYLE_CHANGE,
createHandler(updateStyle, 1,true,"Lorem",["a","b","c"]),
false, 0, true);
this way you can use original event handlers and inject the "arguments" to it,
also you could have your handlers to have following signature:
protected function myHandler(e:Event, ...args):void;
then you could pass arguments directly to the target handler:
protected function createHandler(handler:Function, ...args):Function
{
var h:Function = function(e:Event = null):void
{
//trace(args);
if (handler != null)
{
args.unshift(e);
handler.apply(this, args);
}
}
return h;
}
best regards