Hi,
I have a function that uses the ... rest argument as follows:
public function dispatchActions(... actions):void
{
var params:Object = new Object();
params.actions = actions; // I also tried casting ie. = (actions as Array)
this.target.dispatchEvent(new ActionEvent(ActionEvent.dispatchActions, params));
}
I call it using myActionObject.dispatchActions("all");
The problem is that when a listener receives the dispatched params object and try to access the actions array, it does nothing. If I try to trace evt.params.actions
it traces blank and if I try to trace evt.params.actions[0]
it traces undefined.
ex:
function actionsListener(evt:ActionEvent):void
{
var actions:Array = (evt.params.actions) as Array; // I also tried without casting
trace("actions", actions, "actions 0", actions[0], "action 1", actions[1]);
}
This is the output: actions actions 0 undefined actions 1 undefined
What is wrong here? I don't understand why I can't pass the ... rest argument through an object as an event parameter. How can I make this work?
Thank You.