1

I'd like to implement a RESTful API which returns HTTP error codes when needed. Can ActionScript 3 handle an HTTP error code (404, 500) response which contains a JSON message in its payload?

Are there any good references that I can use as feedback for our in-house Flash front-end team?

  • Possible duplicate of [How to access AS3 URLLoader return data on IOErrorEvent](http://stackoverflow.com/questions/188887/how-to-access-as3-urlloader-return-data-on-ioerrorevent) –  Feb 13 '17 at 18:44

2 Answers2

0

I've been struggling with this too. It seems that the answer is "no", AS3 cannot.

I have, intermittently, seen data come in through IOErrorEvent.currentTarget.data, but I am not able to consistently reproduce this.

-1

You probably can do URLRequest and then handle the HTTP status

var loader:URLLoader = new URLLoader();

var request:URLRequest = new URLRequest("XMLFile.xml");
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

private function httpStatusHandler(event:HTTPStatusEvent):void {
      trace("httpStatusHandler: " + event);
}

loader.load(request);

check the complete example : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html

you can add dispatcher.addEventListener(Event.COMPLETE, completeHandler); to find out whats coming back.

freezing_
  • 984
  • 1
  • 9
  • 13
  • If the server has sent back 404 with a JSON payload, will loader.load(request) still receive the payload? Or does AS3 short circuit the response returning only the 404 status? – Carlos Justiniano Oct 21 '13 at 23:18
  • -1 I've tested this solution and it doesn't seem to work. The "complete" event never gets hit after the "ioError" event happens. –  Feb 13 '17 at 18:40