Search code examples
actionscript-3flasheventsioerror

Can you get the IOError that caused the IOErrorEvent?


In a Flash/AS3 application, you can get an IOErrorEvent when a I/O operation fails.

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loaded);
loader.addEventListener(IOErrorEvent.IO_ERROR, problem);
loader.load(new URLRequest("config.xml"));

function problem(e:IOErrorEvent)
{
    trace(e.toString());
}

I would like to know what failed. Is there a way to get the IOError from the event? The toString() method doesn't give us a lot of information, nor do any others.


Solution

  • IOErrorEvent is the error: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/IOErrorEvent.html

    It has all the things you need:

    • errorID - the reference number
    • target/currentTarget - the one that dispatches it
    • text
    • type - the type of the error (check here for list of IO constants)

    I can't think of something else you might want to know :)