如何为URLRequest发送参数

时间:2014-04-23 23:58:45

标签: actionscript-3 flex flex4

我已经在PHP中发送了我的后端参数,但我有代码而且我没有发送参数看

var request:URLRequest = new URLRequest(modelLocator.CaminhoServidor+"AnexoDocumentos_Financeiro/asdas/xml.php");
            var loader:URLLoader = new URLLoader();
            loader.dataFormat = URLLoaderDataFormat.VARIABLES;
            request.data = Remessa;
            request.method = URLRequestMethod.POST;
            loader.addEventListener(Event.COMPLETE, RecebeXML);
            loader.load(request);

如何发送3个参数这段代码?

1 个答案:

答案 0 :(得分:0)

您需要使用URLRequest对象中的'variables'字段:

var request:URLRequest = new URLRequest(url);
request.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.param1 = ...
variables.param2 = ...
variables.param3 = ...
request.data = variables;

var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlLoader_error);
urlLoader.load(request);

此外,为错误定义处理程序是个好主意(如上面的IO_ERROR所示,还有HTTP_STATUS和SECURITY_ERROR)