
86
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.1
Server-Side ActionScript Language Reference
Last updated 7/2/2013
Details
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 Adobe Media Server did not try to make the URL request.
If Adobe Media Server cannot get a status code, or if it cannot communicate with the server, the default value of 0 is
passed to your ActionScript code.
Example
The following example shows how to use onHTTPStatus() to help with debugging. The example collects HTTP status
codes and assigns their value and type to an instance of the LoadVars object. (Notice that this example creates the
instance members
this.httpStatus and this.httpStatusType at runtime.) The onData() handler uses these
instance members to trace information about the HTTP response that can be useful in debugging.
var myLoadVars = new LoadVars();
myLoadVars.onHTTPStatus = function(httpStatus) {
this.httpStatus = httpStatus;
if(httpStatus < 100) {
this.httpStatusType = "flashError";
}
else if(httpStatus < 200) {
this.httpStatusType = "informational";
}
else if(httpStatus < 300) {
this.httpStatusType = "successful";
}
else if(httpStatus < 400) {
this.httpStatusType = "redirection";
}
else if(httpStatus < 500) {
this.httpStatusType = "clientError";
}
else if(httpStatus < 600) {
this.httpStatusType = "serverError";
}
}
myLoadVars.onData = function(src) {
trace(">> " + this.httpStatusType + ": " + this.httpStatus);
if(src != undefined) {
this.decode(src);
this.loaded = true;
this.onLoad(true);
}
else {
this.onLoad(false);
}
}
myLoadVars.onLoad = function(success) {}
myLoadVars.load("http://weblogs.macromedia.com/mxna/flashservices/getMostRecentPosts.cfm");
Comentarios a estos manuales