In the following code, I set up and process a user typing in a username and password. The code has handlers for success and failure; but it doesn’t seem to be able to handle a situation where the gateway.php is missing (or the user lost their internet connection). Instead of returning me to (currently) the failure frame, it just sits there and I get Error opening URL “http://localhost/amfphp/gateway.php” in the output window. Would someone please help me understand how to handle this situation?
import mx.remoting.*;
import mx.rpc.*;
import mx.utils.Delegate;
import mx.remoting.debug.NetDebug;
NetDebug.initialize();
var gatewayUrl:String = "http://localhost/amfphp/gateway.php";
var service = null;
function handleLoginResponse(re:ResultEvent){
trace("<handleLoginResponse>: we called login succesfully: " + re.result + " Going to loading screen");
// Authentication Successful
if( re.result == '0' ) {
//showLogin();
loadingStatusHolderMC.lsMC.gotoAndPlay("success");
loadingStatusHolderMC.lsMC.firstName.text = user;
}
// Authentication Failure
else {
trace( "<handleLoginError>: we caught an error in login: "+re.result);
//showLogin();
loadingStatusHolderMC.lsMC.gotoAndStop("failure");
}
}
function handleLoginError(re:ResultEvent){
trace( "<handleLoginError>: we caught an error in login: "+re.result);
}
function login(user, pass){
trace( "Login for User: "+user);
var pc:PendingCall = service.login(user,pass);
pc.responder = new RelayResponder(this, "handleLoginResponse", "handleLoginError");
showLogin(); // After hitting ENTER, the code goes here first
loadingStatusHolderMC.lsMC.gotoAndStop("loading");
}
I am not concerned with the status of my gateway - it works fine - I want to be able to handle an inability to connect to it.
[COLOR=DarkOrange]Thanks![/COLOR]