我正在使用httpservice,一旦它被调用没有任何反应。我没有得到结果或错误?我添加了各种监听器但无法捕获任何错误。我错过了什么吗?
private function GetUsersServers():void
{
var serviceObj:HTTPService = new HTTPService();
serviceObj.resultFormat = 'text';
serviceObj.method = 'GET';
serviceObj.useProxy = false;
serviceObj.addEventListener(ResultEvent.RESULT, GetUsersServersResult);
serviceObj.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
serviceObj.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
serviceObj.addEventListener(Event.COMPLETE, onLoadComplete);
serviceObj.url = '************************';
var parameters:Object = new Object();
parameters["Username"] = m_strUserSIP;
LogAddItem( -1, "GetUsersServers Request - User = " + parameters.Username);
serviceObj.send(parameters);
}
private function onLoadComplete(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "securityErrorHandler: " + loader.data);
}
// check for security error - probably crossdomain issue
private function securityErrorHandler(event:SecurityErrorEvent):void {
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "securityErrorHandler: " + event);
}
public function onLoadError(e:IOErrorEvent):void {
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "Fault: " + e.text);
}
private function GetUsersServersResult(event:ResultEvent):void
{
LogAddItem( -1, "GetUsersServers Result Received..");
var rawData:String = String(event.result);
LogAddItem( -1, "GetUsersServersResult = " + rawData);
InitContinue();
}
答案 0 :(得分:0)
问题很可能是您在函数HTTPService
中声明了GetUsersServers()
。当该函数完成时,持有HTTPService
的变量不再存在,并且有资格进行垃圾收集。
相反,如果您将HTTPService
声明为成员变量,则该变量将在该类的整个生命周期内存在。请尝试这样的事情:
private var serviceObj:HTTPService;
private function GetUsersServers():void
{
serviceObj = new HTTPService();
...
}