Suppose in your *.as file you have a block of code like this:
function connectExample() {mx.remoting.debug.NetDebug.initialize();remoteService = new Service(remoteServiceUrl, null, remoteServiceName, null, null);
remoteService.connection.setCredentials(_global.user, _global.password);}function onStatus(stat:Object) {trace("stat.code##"+stat.code);Alert("stat.code##"+stat.code);}
Instead of use remoteService = new Service(remoteServiceUrl, null, remoteServiceName, null, null); change it to the following:
var conn:Connection = new Connection();conn.onStatus = function( info ):Void {if (info == undefined) {Alert.show("Network Error, please try again later.");trace("The host can’t be reached, show user the network connection error");} else {trace("onStatus: " + info.code);}}conn.connect(remoteServiceUrl);remoteService= new Service(null, null, remoteServiceName, conn);
You can test it by unplug your network cable or disable your network connection then submit your request to the server. The user interface should have an alert windows with the message that you set.
0 comments:
Post a Comment