在尝试连接到外部文件时,我无法正确识别何时未建立连接。如果我打开 localhost(即 config.gateway1),它工作正常,但如果我关闭服务器,我只会收到一个错误:
“错误打开 URL 'http://localhost/amfphp/gateway.php'”
我已经尝试在连接和呼叫上设置尝试捕获。我还设置了一个事件监听器,它应该调用一个 onFailure 函数(此时它只是跟踪失败)。当我拨打电话时似乎发生了错误,但它不起作用......但我似乎无法指示发生错误时会发生什么。
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);