MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 642

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Flash Player 8 introduced the
and MovieClipLoader class to allow users to access the status code from an HTTP request.
This allows developers to determine why a particular load operation may have failed instead of
only being able to determine that a load operation already has failed.
The following example shows how you can use the LoadVars class's
handler to check whether a text file successfully downloaded from the server and what the
status code returned from the HTTP request was.
To check HTTP status with the LoadVars object:
1.
Create a new Flash document and save it as loadvars.fla.
2.
Add the following ActionScript to Frame 1 of the main Timeline:
this.createTextField("params_txt", 10, 10, 10, 100, 21);
params_txt.autoSize = "left";
var my_lv:LoadVars = new LoadVars();
my_lv.onHTTPStatus = function(httpStatus:Number) {
trace("HTTP status is: " + httpStatus);
};
my_lv.onLoad = function(success:Boolean) {
if (success) {
trace("text file successfully loaded");
params_txt.text = my_lv.dayNames;
} else {
params_txt.text = "unable to load text file";
}
};
my_lv.load("http://www.helpexamples.com/flash/404.txt");
/* output:
Error opening URL "http://www.helpexamples.com/flash/404.txt"
HTTP status is: 404
*/
642
Working with External Data
event handler for the LoadVars class, XML class,
onHTTPStatus
event
onHTTPStatus

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents