AIR API Tip: Use HTTP_RESPONSE_STATUS, not HTTP_STATUS

AIR extends the existing Flash URLLoader, URLStream, and FileReference classes with a new event type, HTTP_RESPONSE_STATUS. If you’re writing an AIR application, you probably want to use this new event instead of HTTP_STATUS. Both events are instances of HTTPStatusEvent, but there are two major differences.

Additional Properties The HTTPStatusEvent has two new properties, responseHeaders and responseURL. These properties are available for HTTP_RESPONSE_STATUS but not HTTP_STATUS.

Earlier Dispatch The HTTP_STATUS event is dispatched after the request is completed and immediately before the COMPLETE event itself is sent. HTTP_RESPONSE_STATUS is dispatched as soon as the headers have been processed, before the data is available. If your request contains a lot of data or is made over a slow link, this can be significantly earlier.

Why did AIR introduce the new event type, instead of just re-using HTTP_STATUS? Compatibility: We didn’t want to break any existing code.

One Response to AIR API Tip: Use HTTP_RESPONSE_STATUS, not HTTP_STATUS

  1. Gilang says:

    Hi Sir..Would you mind to giving me a usage example of this event? I’m using HTML/JavaScript. I’m trying to access file header information from server.Thanks[You can find an example of HTTP_STATUS in the HTTPStatusEvent documentation and easily adapt it to HTTP_RESPONSE_STATUS. See also Accessing AIR APIs from JavaScript. -Oliver]