Im creating an application on Adobe Flex mobile (Blackberry playbook to be exact). Im designing an app that has a search function that makes a simple HTTP request to a serve开发者_运维知识库r and waits for a response...
When the user clicks on search, how do I create an alert box that says "Searching..." and doesn't disappear until we get an HTTP response?
Thanks Phil
add event listener to HTTP object that listen the response
then show the dialog on start search and hide it when response listener is called
private var service:HTTPService
public function useHttpService(parameters:Object):void {
service = new HTTPService();
service.destination = "sampleDestination";
service.method = "POST";
service.addEventListener("result", httpResult);
service.addEventListener("fault", httpFault);
service.send(parameters);
}
public function httpResult(event:ResultEvent):void {
var result:Object = event.result;
//in your case show the dialog on search click and hide the dialog here.
}
public function httpFault(event:FaultEvent):void {
var faultstring:String = event.fault.faultString;
Alert.show(faultstring);
}
]]>
</mx:Script>
精彩评论