
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
65
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")
;
LoadVars.onLoad()
myLoadVars.onLoad(success){}
Invoked when a LoadVars.load() or LoadVars.sendAndLoad() operation has completed. If the variables load
successfully, the
success parameter is true. If the variables were not received, or if an error occurred in receiving
the response from the server, the
success parameter is false.
If the
success parameter is true, the myLoadVars object is populated with variables downloaded by the
LoadVars.load() or LoadVars.sendAndLoad() operation, and these variables are available when the onLoad()
handler is invoked.
Commenti su questo manuale