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].
- 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:
- 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".
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].
|