-
Ok, I've been experimenting with XML and Flash for about a week and found nothing but frustration. I can load variables from a local text file, but when I try to load an XML file it doesn't seem to be loading.
Here is a copy of the code, very simple:
// Frame 1
myDocument = new XML();
myDocument.load("race.xml");
for (i=0; i<100; i++); {
if (myDocument.loaded) {
var test = "Document Loaded";
i = 101;
} else {
var test = "Document has not loaded yet!";
}
}
// Frame 2
var test2 = "Document Did Not Load!";
stop();
Any jump out at anyone? The xml file is in the same folder as the flash movie. But doesn't seem to be working for me. It seems simple enough, but something isn't right.
Any help would be greatly appreciated.
-Joe
-
K....
Here's the contents of the Movie Explorer window for a FLA that loads an external XML file from the same directory. You can find a Zip file of everything you need here: http://www.thelought.com/loadingTest.zip
I've commented the code here, so that you don't really have to download it if you don't want to... The FLA has no comments.
Scene 1
(textBox), (_root.lStatus)
m_poo, (poo)
(textBox), (_root.rootData)
(textBox), (_root.targetedData)
b_findBoth
actions for b_findBoth
on (release) {
trace ("Finding...");
// This sets one text box equal to a supposed location on the root... which will prove that the XML is NOT loaded into the root...
_root.rootData = _root.menuXML.toString();
// This sets the other text box equal to the real location, where we told the XML to go...
_root.targetedData = _root.poo.xml.menuXML.toString();
}
Symbol Definition(s)
m_poo
m_xml, (xml)
b_load
actions for b_load
on (release) {
trace ("Loading...");
// Targets the XML object and tells it to use its 'load' method to populate itself with an external XML file...
xml.menuXML.load("test.xml");
}
b_findBoth
m_xml
actions for frame 1
// Instantiates the XML object
menuXML = new XML();
// Sets the onLoad handler so that we know when the XML document has been loaded into the XML object...
menuXML.onLoad = parseXML;
_root.lStatus = "Loading data...";
// Initializes the 'onLoad' handling function - I chose the variable 'loadStatus' to represent the Boolean condition signifying complete/incomplete loading of the XML document into the XML object........
function parseXML (loadStatus) {
if (loadStatus) {
_root.lStatus = "Data loaded.";
} else {
_root.lStatus = "Data NOT loaded.";
}
}
b_load
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|