Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 Knowledgebase
Loading An XML File Into An Array I  

First of all create a simple xml file using a compatible text editor such as Notepad or Dreamweaver for more information see: [How to create a simple xml file].

The XML File

var my_xml = new XML();

my_xml.onLoad = function(success){
if (success){
trace("Document loaded successfully");
}
else{
trace("Did not load or parse!");
}
}
my_xml.load("my_data.xml");

Download .xml

  • Open flash and create a new .fla file
  • Then save the file in the same folder as the xml file you want to load.
  • Open the actionscript panel in flash and paste the following code:

Actionscript

var my_xml = new XML();

my_xml.onLoad = function(success){
if (success){
trace("Document loaded successfully");
}
else{
trace("Did not load or parse!");
}
}
my_xml.load("my_data.xml");

Download .fla
Note: In this example I am loading the xml file called "my_data.xml".

How This Actionscript Works

Note: One of the most important things to remember when working with data from XML you should make sure the xml file is fully loaded before you access the data.



Note: The xml data file must exist in the same directory folder as the .fla or swf file for flash to correctly follow the folder path. To learn more about XML in flash see [XML Knowledgebase].


© 2008 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us