⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proxyfunction.as

📁 使用Flash提供的Web Service的能力
💻 AS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -