I recently discovered something interesting trying to implement a REST API call in an AIR application.
When you load a URL request in Flex, you usually listen for complete, I/O error and security error events on the loader. However, I’ve learned that it’s important to also listen for HTTP response status events when loading a URL request in AIR.
Otherwise you might not receive a response when the result is anything other than success (200). Instead, you’ll receive an I/O error: “Error #2032: Stream Error.”
Consider the following sample code:
|
var loader : URLLoader = new URLLoader (); loader.addEventListener (Event.COMPLETE, onComplete); loader.addEventListener (IOErrorEvent.IO_ERROR, onIOError); loader.addEventListener (SecurityErrorEvent.SECURITY_ERROR, onSecurityError); // AIR-only! loader.addEventListener (HTTPStatusEvent.HTTP_RESPONSE_STATUS, onHTTPStatus); loader.load (request); |
No action is required in the onHTTPStatus() method above. As long as you are listening for the event, you will always receive a response.

1 comment
Comments feed for this article
April 2, 2009 at 2:37 pm
HTTP Status 201 causing Flex #2032 Error in IE only — Thanks, Mister!
[...] Saw another blog post about the same topic at UserFlex. [...]