我将致电flashObject.httpRequest
以通过Flash完成http
请求。
问题是没有参考httpRequest
是异步方法还是同步。
这对我的申请很重要。
private function httpRequest (uri:String, param:String="", method:String="GET"):void
{
var
urlRequest:URLRequest = new URLRequest(uri),
urlLoader:URLLoader = new URLLoader();
method = method.toLowerCase();
switch (method)
{
case "get":
urlRequest.method = URLRequestMethod.GET;
break;
case "post":
urlRequest.method = URLRequestMethod.POST;
break;
default:
urlRequest.method = URLRequestMethod.GET;
}
urlRequest.contentType = "text/plain; charset=utf-8";
urlRequest.requestHeaders.push(new URLRequestHeader("X-Requested-From", "Flash"));
urlRequest.data = param;
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, urlRequestComplete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlRequestError);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, urlRequestError);
urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, urlRequestProcessing);
try {
urlLoader.load(urlRequest);
} catch (error:Error) {
ExternalInterface.call("onerror","error");
}
}
答案 0 :(得分:0)
httpRequest
是一种Sync方法。 :)