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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

The following example shows how you can use the XML class's
to check whether an XML file successfully downloaded from the server and what the status
code returned from the HTTP request was.
Checking HTTP status codes using the XML class:
1.
Create a new Flash document and save it as xmlhttp.fla.
2.
Add the following ActionScript to Frame 1 of the main Timeline:
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onHTTPStatus = function(httpStatus:Number) {
trace("HTTP status is: " + httpStatus);
};
my_xml.onLoad = function(success:Boolean) {
if (success) {
trace("XML successfully loaded");
// 0 (No error; parse was completed successfully.)
trace("XML status is: " + my_xml.status);
} else {
trace("unable to load XML");
}
};
my_xml.load("http://www.helpexamples.com/crossdomain.xml");
The previous code defines a new XML object with the variable name
event handlers (
onHTTPStatus
event handler checks to see whether the XML file was successfully loaded and if so sends a
message to the Output panel as well as traces the XML object's status property. It is
important to remember that the
returned from the web server, whereas the
that indicates whether the XML object was able to be parsed successfully.
3.
Select Control > Test Movie to test the Flash document.
The
XML.onHTTPStatus
Don't confuse the HTTP httpStatus codes with the XML class's
onHTTPStatus
and the
status
whether an XML document was successfully parsed into an XML object.
If a web server does not return a
returned to the
and
onLoad
onHTTPStatus
event handler is new to Flash Player 8.
event handler returns the server's status code from an HTTP request
property automatically sets and returns a numeric value that indicates
status
event handler.
onHTTPStatus
onHTTPStatus
), and loads an external XML file. The
event listener returns the status code
property contains a numeric value
XML.status
code to the Flash Player, the number 0 is
event handler
, defines two
my_xml
onLoad
property. The
status
About XML
659

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?

This manual is also suitable for:

Flash 8

Table of Contents