Actionscript 3 跟踪as3中的网络连接错误
在尝试连接到外部文件时,我无法正确识别何时未建立连接。如果我打开了localhost(即config.gateway1),它可以正常工作,但是如果我关闭服务器,我只会得到一个错误: “打开URL时出错”http://localhost/amfphp/gateway.php"" 我已尝试在连接和通话中设置try-catch。我还设置了一个事件侦听器,它应该在失败时调用函数(此时只跟踪失败)。错误似乎发生在我打电话的时候,它不起作用……但我似乎无法指示错误发生时会发生什么Actionscript 3 跟踪as3中的网络连接错误,actionscript-3,flash,netconnection,Actionscript 3,Flash,Netconnection,在尝试连接到外部文件时,我无法正确识别何时未建立连接。如果我打开了localhost(即config.gateway1),它可以正常工作,但是如果我关闭服务器,我只会得到一个错误: “打开URL时出错”http://localhost/amfphp/gateway.php"" 我已尝试在连接和通话中设置try-catch。我还设置了一个事件侦听器,它应该在失败时调用函数(此时只跟踪失败)。错误似乎发生在我打电话的时候,它不起作用……但我似乎无法指示错误发生时会发生什么 var gatew
var gateway1:String = config.gateway1
var gateway2:String = config.gateway2
var connection:NetConnection = new NetConnection ;
connection.addEventListener(IOErrorEvent.IO_ERROR,onFailure);
try{
connection.connect(gateway1);
trace("It went in to the try of the connection.connect")
//trace(connection);
}
catch(error:IOError){
trace("It didn't work",error);
}
var responder:Responder = new Responder(onResult,onFault);//onResult and onFault can be any name
var array:Array = new Array(kioskNum,questionNum);
try
{connection.call("dataconnect.retrieveInfo",responder,array);
trace("It went in to the try of the connection.call");}
catch(error:IOError){
trace("It didn't work",error);}
//trace(gateway1);
您需要为添加事件侦听器并检查:
您需要为添加事件侦听器并检查:
加载WSDL时出错可以使用FaultEvent.FAULT捕获
...
webService.addEventListener(FaultEvent.FAULT, onWsdlLoadError);
webService.loadWsdl(<wsdl>);
...
protected function onWsdlLoadError(event:FaultEvent):void {
trace("wsdl load error: " + event.fault);
}
。。。
addEventListener(FaultEvent.FAULT,onWsdlLoadError);
loadWsdl();
...
受保护的函数onWsdlLoadError(事件:FaultEvent):无效{
跟踪(“wsdl加载错误:+event.fault”);
}
希望这有帮助。加载WSDL时的错误可以通过使用FaultEvent.FAULT捕获
...
webService.addEventListener(FaultEvent.FAULT, onWsdlLoadError);
webService.loadWsdl(<wsdl>);
...
protected function onWsdlLoadError(event:FaultEvent):void {
trace("wsdl load error: " + event.fault);
}
。。。
addEventListener(FaultEvent.FAULT,onWsdlLoadError);
loadWsdl();
...
受保护的函数onWsdlLoadError(事件:FaultEvent):无效{
跟踪(“wsdl加载错误:+event.fault”);
}
希望这有帮助。在调试时,我还使用了一个默认案例来跟踪所有其他网络状态事件代码,这有时会非常有启发性
default:trace(event.info.code);中断非常感谢两位。显然,出于某种原因,我正在寻找的案例是“NetConnection.Call.Failed”。代码的痕迹帮我弄明白了…非常感谢@umamimake我已经更新了我的答案,所以您可能可以接受它。调试时,我还使用默认情况跟踪所有其他网络状态事件代码,这有时会非常有启发性default:trace(event.info.code);中断非常感谢两位。显然,出于某种原因,我正在寻找的案例是“NetConnection.Call.Failed”。代码的痕迹帮我弄明白了…非常感谢@我已经更新了我的答案,所以你可能可以接受。