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));
}
}
}
}
flash中的Remoting
最新推荐文章于 2025-12-17 10:19:46 发布
本文介绍了一个基于 Flash 的 Remoting 类实现,该类通过 NetConnection 进行远程过程调用,支持 AMF3 和 AMF0 编码类型。文章详细解释了构造函数和 respond 方法的工作原理。
958

被折叠的 条评论
为什么被折叠?



