title: tracing a netconnection error in as3
body: <p>I am having a problem with correctly identifying when a connection was NOT made while trying to connect to an external file.  It works fine if I have the localhost on (which is config.gateway1) but if I turn the server off I only get an error:</p>
  
  <p>"Error opening URL 'http://localhost/amfphp/gateway.php'"</p>
  
  <p>I've tried setting up try catches on both the connection and the call.  I also set up an event listener which is supposed to call a function onFailure (which at this point just traces the fail).  The error seems to occur when I make the call, and it doesn't work...but I can't seem to direct what happens when the error occurs.    </p>
  
  <pre><code>    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);
  </code></pre>