Flex / Flash Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: …

When attempting to access a URL via the URLLoader, eg:

var loader:URLLoader = new URLLoader(“some url or uri”);
You get an error:
Flex / Flash Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: …
I modified the code referenced from:
To create an URLErrorHandler that will attach to a URLLoader.  So, to easily attach default error handlers to the above code simply:
new URLErrorHandler(loader);
The code for the URLErrorHandler class is:
package modules
{
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.HTTPStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLLoader;

public class URLErrorHandler
{
private var errorCallback:Function = null;

/*
Specify a callback function on an error if desired.  The callback function prototype is
public function onError(event:Event):void
*/
public function URLErrorHandler(loader:URLLoader, onError:Function = null)
{
if (loader == null)
return;
loader.addEventListener ( IOErrorEvent.IO_ERROR, handleIOError );
loader.addEventListener ( HTTPStatusEvent.HTTP_STATUS, handleHttpStatus );
loader.addEventListener ( SecurityErrorEvent.SECURITY_ERROR, handleSecurityError );
//loader.addEventListener ( Event.COMPLETE, handleComplete );

errorCallback = onError;
}
function handleIOError ( event:IOErrorEvent ):void
{
trace ( “Load failed: IO error: ” + event.text );
if (errorCallback != null) errorCallback(event);
}
function handleHttpStatus ( event:HTTPStatusEvent ):void
{
trace ( “Load failed: HTTP Status = ” + event.status );
//if (errorCallback != null) errorCallback(event);
}
function handleSecurityError ( event:SecurityErrorEvent ):void
{
trace ( “Load failed: Security Error: ” + event.text );
//if (errorCallback != null) errorCallback(event);
}
}
}

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Leave a Reply

You must be logged in to post a comment.