PDA

View Full Version : Passing unknown number of parameters into a function


Bombdogs
11-17-2009, 09:39 AM
Hi all,

I have a project that uses a lot of remoting calls and I'm hoping to abstract the process. I've hit a problem with passing parameters to the final call...

function RemotingCall(flashGateway:String, ...rest):void
{
var gateway:NetConnection = new NetConnection();
gateway.addEventListener(SecurityErrorEvent.SECURI TY_ERROR, gatewayOpeningError);
gateway.addEventListener(IOErrorEvent.IO_ERROR, gatewayOpeningError);
gateway.connect(flashGateway);
var responder:Responder = new Responder(successFunction, failFunction);
// following line, how to construct from the ...rest param?
gateway.call(arg1, arg2, arg3, arg4....)
}


I know how to loop through the ...rest param to obtain their values but I'm struggling at how to construct the final gateway.call() which could have 1 arg or 10.

Thanks.

PMF

majakovskij
11-17-2009, 10:03 AM
maybe you should pass the ...rest param to the call() and in that function parsing the values...

henke37
11-17-2009, 03:15 PM
Function.apply