4 Replies Latest reply on Apr 18, 2006 12:52 PM by eslacker

    XML Object dissapearing?!?!

      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...


        • 1. Re: XML Object dissapearing?!?!
          Dinghus Level 1
          Would have to look at your code to be sure.

          Try this

          *on load*
          function loaded() {
          myXML = this.firstChild;
          • 2. Re: XML Object dissapearing?!?!
            eslacker Level 1
            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("XML loaded");
            trace("Question total: " + _root.questionCount);
            trace("An error occured while loading XML data.");

            var currentQuestion = 0;
            var currentTest = 0;
            testXML = new 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.
            • 3. Re: XML Object dissapearing?!?!
              Peter Lorent Level 2
              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. Re: XML Object dissapearing?!?!
                eslacker Level 1
                See, I *knew* it! It was something silly. Put in a stop() on the first frame and a play in the load function and voila!

                Thanks! Is there a brainfart section to add this one to?

                Take care...