
96
Server-Side ActionScript Language Reference
Example
The following example loads a text file and displays content in a TextArea instance called
content_ta
when the operation completes. If an error occurs, then information displays in
the Output panel. If an error occurs, then information writes to the log file.
var my_lv = new LoadVars();
my_lv.onData = function(src) {
if (src == undefined) {
trace("Error loading content.");
return;
}
content_ta.text = src;
};
my_lv.load("content.txt", my_lv, "GET");
LoadVars.onHTTPStatus
Availability
Flash Media Server 2.
Usage
myLoadVars
.onHTTPStatus(
httpStatus
){}
Parameters
httpStatus
A number; the HTTP status code returned by the server. For example, a value
of 404 indicates that the server has not found a match for the requested URI. HTTP status
codes can be found in sections 10.4 and 10.5 of the
HTTP specification
.
Description
Event handler; invoked when Flash Media Server receives an HTTP status code from the
server. This handler lets you capture and act on HTTP status codes.
The
onHTTPStatus
handler is invoked before
onData
, which triggers calls to
onLoad
with a
value of
undefined
if the load fails. After
onHTTPStatus
is triggered,
onData
is always
triggered, whether or not you override
onHTTPStatus
. To best use the
onHTTPStatus
handler, you should write a function to catch the result of the
onHTTPStatus
call; you can
then use the result in your
onData
and
onLoad
handlers. If
onHTTPStatus
is not invoked, this
indicates that FMS did not try to make the URL request.
If Flash Media Server cannot get a status code from the server, or if it cannot communicate
with the server, the default value of 0 is passed to your ActionScript code.