BeyondTheBlue
Programmer
I'm working on a small project that will act as a sort of Codex, or reference guide. The structure of the movie is kindof like a DVD, with 3 sections, each section with an associated list of chapters. I wanted to be able to put the text information, like the chapter content, header, etc, in an XML file to make it easier to edit and add chapters later. I've used XML before in some limited applications, but I'm doing it differently now than I have before.
What I want is to dump the contents of the XML file into an array that's accessable at the _root level. I can access it from within the xmlData.onLoad function, but I can't seem to figure out how to access in anything that's not a child-function of that event.
I dont' understand why the following code doesn't work:
the trace()command from withing the .onLoad event reports the correct data, but the last line, which is not in the .onLoad event, returns 'undefined'.
Even if I declare _global, _root, or _level0 variables, the .onLoad event handler can't access them.
What's my solution? How can I get access to the XML data in the global scope?
What I want is to dump the contents of the XML file into an array that's accessable at the _root level. I can access it from within the xmlData.onLoad function, but I can't seem to figure out how to access in anything that's not a child-function of that event.
I dont' understand why the following code doesn't work:
Code:
function loadXML(loaded) {
if (loaded) {
S1chapHeader = [];
S1chapContent = [];
xmlSect1Node = this.childNodes[0];
total = xmlSect1Node.childNodes.length;
for (i=0; i<total; i++) {
S1chapHeader[i] = xmlSect1Node.childNodes[i].attributes.chapHeader;
S1chapContent[i] = xmlSect1Node.childNodes[i].attributes.chapContent;
}
trace(this.childNodes[0].childNodes[0].attributes.chapHeader);
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("drift_content.xml");
trace(xmlData.childNodes[0].childNodes[0].attributes.chapHeader);
the trace()command from withing the .onLoad event reports the correct data, but the last line, which is not in the .onLoad event, returns 'undefined'.
Even if I declare _global, _root, or _level0 variables, the .onLoad event handler can't access them.
What's my solution? How can I get access to the XML data in the global scope?