Skip to main content
Participant
April 18, 2006
Answered

XML Object dissapearing?!?!

  • April 18, 2006
  • 4 replies
  • 365 views
Hello, All.

I guess I'm just missing something silly, but I have a weird situation where after I've loaded my XML data and looked at the attributes (w/ trace in the loading function), immediately after "successfully" loading the data, it becomes undefined. Anything obvious that I should check for? This is probably the 10th project of this type that I've done, but it's been a version or so since I've messed with Flash & XML. TIA for any help...

Ciao,

-Jei.
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Peter Lorent
You probably don't wait for the xml to load and then play the next frame. The first frame should have a stop() and in your function load in the if-leg instruct the movie to play the next frame.

4 replies

Inspiring
April 18, 2006
Would have to look at your code to be sure.

Try this

*on load*
function loaded() {
trace(this);
myXML = this.firstChild;
trace(myXML);
}
eslackerAuthor
Participant
April 18, 2006
Thanks for the reply. Yeah, I have all the loading code (nearly identical to another project from a couple years ago). Here's my code:

function loaded(success){
if (success == true) {
_root.rootNode = testXML.firstChild;
_root.testNode = _root.rootNode;
_root.questionNode = _root.testNode.firstChild;
_root.questionCount = _root.testNode.childNodes.length;
_root.testTitle = _root.testNode.attributes.title;
trace(_root.testTitle);
trace("XML loaded");
trace("Question total: " + _root.questionCount);
trace(_root.questionNode.attributes.qText);
}else{
trace("An error occured while loading XML data.");
}
}

var currentQuestion = 0;
var currentTest = 0;
testXML = new XML();
testXML.load("wd_test1.xml");
testXML.onLoad = loaded;
testXML.ignoreWhite = true;

This all appears in the first frame of the first layer of my movie. In the next frame, I try to set the value of a dynamic text box as such:

questionText.htmlText = _root.questionNode[0].attributes.qText;

What I get in the textbox is "undefined." I've traced the values also (in the same frame as the text value assignment) and it's as if the XML object was never created/loaded.
Peter LorentCorrect answer
Inspiring
April 18, 2006
You probably don't wait for the xml to load and then play the next frame. The first frame should have a stop() and in your function load in the if-leg instruct the movie to play the next frame.