• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

URGENT! Not sure if I missed it or messed it--Flash text and XML

Okay I am loading different mc's out of the library and in those mc's are multiple dynamic textfields.  I figured that my AS should look something like this but it does not seem to work:

//load my XML
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.load("Dtext.xml");
my_xml.onLoad = function(success) {
      if (success) {
            main2D.text = my_xml.firstChild.childNodes.childNodes[0].attributes.main2D;
            upgrade2D.text = my_xml.firstChild.childNodes[0].attributes.upgrade2D;
            full2D.text = my_xml.firstChild.childNodes[0].attributes.full2D;
            mus2D.text = my_xml.firstChild.childNodes[0].attributes.mus2D;
            feature2D.text = my_xml.firstChild.childNodes[0].attributes.feature2D;
      } else {
            trace("XML NOT LOADED!");
      }
};
0
frankybones
Asked:
frankybones
  • 2
2 Solutions
 
frankybonesAuthor Commented:
Sorry I guess I should state what the problem is.  My text boxes keep giving a return of "undefined" instead of the text it is supposed to display.
0
 
sam85281Commented:
Should be:

//load my XML
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.load("Dtext.xml");
my_xml.onLoad = function(success) {
     if (success) {
          main2D.text = this.firstChild.childNodes.childNodes[0].attributes.main2D;
          upgrade2D.text = this.firstChild.childNodes[0].attributes.upgrade2D;
          full2D.text = this.firstChild.childNodes[0].attributes.full2D;
          mus2D.text = this.firstChild.childNodes[0].attributes.mus2D;
          feature2D.text = this.firstChild.childNodes[0].attributes.feature2D;
     } else {
          trace("XML NOT LOADED!");
     }
};

-Sam
0
 
Aneesh ChopraCommented:
Hi,

first of all, i found a bug in your code,

childNodes.childNodes[0]  is incorrect
---------
main2D.text = my_xml.firstChild.childNodes.childNodes[0].attributes.main2D;
--------

it should be
--------
main2D.text = my_xml.firstChild.childNodes[0].attributes.main2D;
-----------

secondly, as i fixed above mentioned issue, i am able to see the text for "main2D" textField also.


I generated a sample XML as per your code
----------
<?xml version="1.0"?>
<Root>
      <Child main2D="2d" upgrade2D="upg2d" full2D="f2d" mus2D="mus2d" feature2D="feature2d"/>
</Root>
--------

If you are not able to see data in any of the textField that clearly means, that your xml structure is not as I have shown here... and you are parsing is incorrectly..

I would suggested paste your XML structure also for further assistance.

Rgds
Aneesh
0
 
frankybonesAuthor Commented:
Both of you gave great solutions to my problem.  Thank you both very much, I greatly appreciate it.  I will post extra points for you two a bit later.  I will make a title under this section called "Extra points for Sam & Aneesh."  Again thank you both.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now