Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > XML > load (XML.load method) | |||
public load(url:String) : Boolean
Loads an XML document from the specified URL and replaces the contents of the specified XML object with the downloaded XML data. The URL is relative and is called using HTTP. The load process is asynchronous; it does not finish immediately after the load() method is executed.
When the load() method is executed, the XML object property loaded is set to false. When the XML data finishes downloading, the loaded property is set to true, and the onLoad event handler is invoked. The XML data is not parsed until it is completely downloaded. If the XML object previously contained any XML trees, they are discarded.
You can define a custom function that executes when the onLoad event handler of the XML object is invoked.
Note: If a file being loaded contains non-ASCII characters (as found in many non-English languages), it is recommended that you save the file with UTF-8 or UTF-16 encoding as opposed to a non-Unicode format like ASCII.
When using this method, consider the Flash Player security model:
For Flash Player 8:
For more information, see the following:
For Flash Player 7 and later websites can permit cross-domain access to a resource through a cross-domain policy file. In SWF files of any version running in Flash Player 7 and later, the url parameter must be in exactly the same domain. For example, a SWF file at www.someDomain.com cannot load data from sources at store.someDomain.com because both files are not in the same domain.
In SWF files running in a version of the player earlier than Flash Player 7, the url parameter must be in the same superdomain as the SWF file that issues this call. A superdomain is derived by removing the leftmost component of a file's URL. For example, a SWF file at www.someDomain.com can load data from sources at store.someDomain.com, because both files are in the same superdomain of someDomain.com.
Availability: ActionScript 1.0; Flash Player 5 - The behavior changed in Flash Player 7.
url:String - A string that represents the URL where the XML document to be loaded is located. If the SWF file that issues this call is running in a web browser, url must be in the same domain as the SWF file.
Boolean - A Boolean value of false if no parameter (null) is passed; true otherwise. Use the onLoad() event handler to check the success of a loaded XML document.
The following code example uses the XML.load() method:
// Create a new XML object.
var flooring:XML = new XML();
// Set the ignoreWhite property to true (default value is false).
flooring.ignoreWhite = true;
// After loading is complete, trace the XML object.
flooring.onLoad = function(success) {
trace(flooring);
};
// Load the XML into the flooring object.
flooring.load("flooring.xml");
For the contents of the flooring.xml file, and the output that this example produces, see the example for the XML.ignoreWhite property.
ignoreWhite (XML.ignoreWhite property), loaded (XML.loaded property), onLoad (XML.onLoad handler), useCodepage (System.useCodepage property)
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00002333.html