Luk*_*uke 4 remoting actionscript-3
我在我自己的RemoteObject类中封装了对远程服务的调用.这一切都正常,除非我必须处理传递给远程调用的变量参数.因为这是对它的调用,所以NetConnection.call
我应该能够传递变量参数,但因为我正在封装NetConnection.call
它会引发错误.这就是我的方法目前的样子:
public function call( method : String, callback : Function, ... args ) : void
{
var responder : Responder;
responder = new Responder( callback, onResponderStatus );
this._nc.call( this._remoteObject + "." + method, responder, args );
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我的方法将变量arguments参数作为最后一个参数.我正在尝试将这些参数传递给NetConnection.call
方法.但是,在我的方法范围内,args
将是Array类型.如何正确转发变量参数NetConnection.call
?
Function::apply
是你在寻找...最后,它应该是这样的:
this._nc.call.apply(this._nc, [this._remoteObject + "." + method, responder].concat(args) );
Run Code Online (Sandbox Code Playgroud)
格尔茨
back2dos