# \[AS3.0\] Handling URLLoader's Error Event

**URL:** <https://forum.kirupa.com/t/as3-0-handling-urlloaders-error-event/209189>\
**Category:** flash\
**Created:** [December 6, 2006, 6:14pm UTC](https://forum.kirupa.com/t/as3-0-handling-urlloaders-error-event/209189 "2006-12-06T18:14:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![watcher](https://avatars.discourse-cdn.com/v4/letter/w/77aa72/32.png) [@watcher](https://forum.kirupa.com/u/watcher)\
**Post date:** [December 6, 2006, 6:14pm UTC](https://forum.kirupa.com/t/as3-0-handling-urlloaders-error-event/209189/1 "2006-12-06T18:14:11Z")

</div>

Hi there,

the \*\*problem \*\*is simple: [COLOR=#000000]there is a file[/COLOR] (php script) stored remotely on the server, and i want to read it into flash using **AS3.0** ’s URLLoader. However, if i unplug my cable just before reading the file, and attempt to read the file, i want to **capture an Error event** in some error handler, which would mean “internet connection is down, file can not be accessed”.

I am reading the AS3.0 documentation now for 2 hours already (mainly: “Handling **asyn** chronous errors in an application” and “Events of URLLoader class”), but i didnt stumble across an example of how to catch an Error event of the URLLoader object when reading a remote file from the server.

However i took all possible events i could find (even those which are not necessary at all), and tested them in the following code:

```auto

public function URLLoaderTest( ) {
  _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);
}

```

This code traces tons of data, when executed with internet connection up:

```auto

[COLOR=DarkGreen]*openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2]
progressHandler loaded:10 total: 30
httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=0]
completeHandler data: 1165428133*[/COLOR]

```

but it traces **NOTHING** (?!), if the connection is down (wether closed by firewall, or cable-unplugged). So that basically means, none of the above events is fired, none of them takes care of the errorHandling in case of no-internet-connection (or if for some reason we can’t reach the server atm).

Anybody knows what (if there is any) ErrorEvent i can use to catch such (connection down) Error Event?

Or do i have to use Timer class instead to check wether the server responded in some time or not? I would like to leave this as the last option.

Thank You for your care. 🙂
