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!");
      }
};
frankybonesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.