package {
import flash.net.Responder;
import flash.net.NetConnection;
public class Remoting extends NetConnection {
/*
构造
@param gatewayURL remoting网关地址
@param amfType 使用AMF3或AMF0
*/
public function Remoting(gatewayURL:String,amfType:uint) {
super();
this.objectEncoding=amfType;
this.connect(gatewayURL);
}
/*
* 远程返回函数
* @param remoteMethod:远程类.方法名param远程方法所需要的参数onResultFun:返回数据所调用的方法句柄.onFaultFun同理.
*
*/
public function respond(remoteMethod:String,onResultFun:*,onFaultFun:*,... param):void {
var parameters:Array=param;
if (param.length > 0) {
parameters.unshift(remoteMethod,new Responder(onResultFun,onFaultFun));
this.call.apply(this,parameters);
} else {
this.call(remoteMethod,new Responder(onResultFun,onFaultFun));
}
}
}
}