制作HTT prequest并得到响应(Adobe Flex的) [英] Making HTTPRequest and getting response (Adobe Flex)

查看:223
本文介绍了制作HTT prequest并得到响应(Adobe Flex的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着做一个HTTP请求在Adobe Flex的(动作脚本)如下:

Im trying to make a HTTP Request in Adobe Flex (Actionscript) as follows:

var p:PersonSearchController = new PersonSearchController();
showAlertDialog();
p.search(sc);
alert.cancel();

navigator.pushView(views.PersonSearchResults, +p.getResp());

因此​​,基本上,在搜索,我们得到一个搜索...AlertDialog中,一旦搜索完成后,对话框消失,结果屏幕推到屏幕上......

So basically, before the search we get a "Searching..." AlertDialog box, once the search is complete, the dialog box disappears and the results screen is pushed onto the screen...

下面是搜索方法:

function search{
var requestSender:URLLoader= new URLLoader();

dispatcher.addEventListener(Event.COMPLETE, completeHandler);

var urlRequest :URLRequest = new URLRequest("http://airpoint05:8888/MPS2/PersonSearch");

var msg:String = "blah";

/* Setup HTTP Request */
urlRequest.data = msg;
urlRequest.contentType = "application/x-www-form-urlencoded";
urlRequest.method = URLRequestMethod.POST;
requestSender.load(urlRequest);
}

这里是在completeHandler功能:

And here is the completeHandler function:

/* URL has completed and got a response */
private function completeHandler(event:Event):void
{
    var response:URLLoader = URLLoader(event.target);
    this.res = URLLoader(event.target).data;
    trace(this.res);
    response.close();   
}

在这条线被称为:navigator.pushView(views.PersonSearchResults,+ p.getResp());

When this line is called: navigator.pushView(views.PersonSearchResults, +p.getResp());

p.getResp()是毫无作为的反应还没有回来呢。我希望该计划基本上阻塞,直到HTT presponse收到这样我就可以处理结果。此刻的弹出显示,并迅速消失,而在后台搜索熄灭,使得请求......我得到的响应,但只有在结果屏幕已被推出来。我怎样才能让弹出块,直到我们有一个HTT presponse?

p.getResp() is nothing as the response hasn't came back yet. I want the program to basically block until the HTTPResponse is received so I can process the results. At the moment the Popup appear and disappears quickly, and in the background the search goes off and makes the request... I get the response but only after the results screen has been pushed out. How can I make the popup block until we have a HTTPresponse?

谢谢 菲尔

推荐答案

不要使用的URLLoader对于这一点,使用的HTTPService:

Don't use URLLoader for this, use HTTPService:

<fx:Script>
<![CDATA[
private function search(text:String):void
{
service.send({search:text}); // your service will receive the variable 'search' with your string
}

private function resultHandler(e:ResultEvent):void
{
var data:Object = e.result;
// do whatever else here
}
]]>
</fx:Script>
<s:HTTPService id="service" method="POST" url="http://airpoint05:8888/MPS2/PersonSearch" result="resultHandler" />

这篇关于制作HTT prequest并得到响应(Adobe Flex的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆