proxyfunction.as
来自「使用Flash提供的Web Service的能力」· AS 代码 · 共 48 行
AS
48 行
import mx.events.EventDispatcher;
dynamic class XMLRPC.ProxyFunction {
private var res:XML;
private var req:XML;
private var url:String;
private var unmarshaller:XMLRPC.Unmarshaller;
public function ProxyFunction(fn_name:String, fn_params:Array, url:String) {
EventDispatcher.initialize(this);
//create XML objects to hold the request and the response
this.req = new XMLRPC.Marshaller().ASToXML(fn_name, fn_params);
this.res = new XML();
this.res.ignoreWhite = true;
//store the URL
this.url = url;
//create one unmarshaller for now
this.unmarshaller = new XMLRPC.Unmarshaller();
//register the callback function if it exists
var self = this;
this.res.onLoad = function (success:Boolean) {
var o = new Object();
o.type = "On"+fn_name;
//unmarshal the result
if(success) {
o.target = self.unmarshaller.XMLToAS(self.res);
}
// or indicate a problem connecting with the server
else {
var r = new XMLRPC.Result();
r.Fault = {code: 2, description: "Could not connect to server"}
o.target = r;
}
self.dispatchEvent(o);
};
}
public function Execute() {
//send a request and wait for a response
this.req.sendAndLoad(this.url, this.res);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?