If I try to load a file with URLLoader and the internet connection is dead, I get a an Error #2044:Unhandled ioError:.text=Error #2032 message box (on a phone, the internet may die at any time.) Is there anyway I can catch this and prevent it from showing up?
Here’s the error handling I’m using (straight from the documentation):
p[COLOR=#333333][FONT=Consolas]ublic function URLLoaderTest( ) {[/FONT][/COLOR] _loader = new URLLoader( ); // _loader is private var of this class
configureListeners(_loader);
var request:URLRequest = new URLRequest("url_with_php_script");
_loader.load(request);
}
// LISTENERS
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(Event.OPEN, openHandler);
dispatcher.addEventListener(ErrorEvent.ERROR, onError)
dispatcher.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
dispatcher.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
// HANDLERS
private function completeHandler(event:Event):void {
trace("completeHandler data: " + event.currentTarget.data);
}
private function openHandler(event:Event):void {
trace("openHandler: " + event);
}
private function onError(event:ErrorEvent):void {
trace("onError: " + event.type);
}
private function onAsyncError(event:AsyncErrorEvent):void {
trace("onAsyncError: " + event);
}
private function onNetStatus(event:NetStatusEvent):void {
trace("onNetStatus: " + event);
}
private function progressHandler(event:ProgressEvent):void {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event); [COLOR=#333333][FONT=Consolas]}[/FONT][/COLOR]
The stack trace implies the exception is coming from here:
_loader = new URLLoader( )
But if I debug, the execution gets past this line and the exception is thrown from some mysterious place instead.
Thanks in advance! (Sorry for cross posting this in the AS2 and Earlier thread. Someone posted from 2006 and never got a response.)