I want to detect the network disconnection for my web app.
For AIR application it is possible, using the AIR URLMonitor. And in Flash AS3 I am using javascript's
'navigator.onLine' using ExternalInterface.
But the above code does not work always.
Do I have to write my own code to continuously check if my network connection is persistent?
You need to create an URLLoader and look for a response from your website on a timer tick.
var checkTimer:Timer = new Timer(1000);
var checkLoader:URLLoader = new URLLoader();
var checkURL:URLRequest = new URLRequest("mysite");
checkLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
checkTimer.addEventListener(TimerEvent.TIMER, checkURL);
checkTimer.start();
function checkURL(e:TimerEvent):void
{
checkLoader.load(checkURL);
}
function onIOError(e:IOErrorEvent):void
{
//down
}
This is basically the same behaviour as URLMonitor's.