1 Reply Latest reply on Apr 23, 2008 11:09 AM by FlashTastic

    Get Numbers with xml and flash

    CSFORM_31
      Hello
      I have this problem getting the numbers from a xml to flash because I only getting two-digit and hay need to get like 8 or more digit numbers and I dont know what happen.

      Here is the AS 2 code:

      var mybook:Number = 0;
      var mymagazine:Number = 0;
      var mycolor:Color = new Color(mccolor);
      function loadXML(loaded) {
      if (loaded) {
      _root.tienda = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
      _root.books = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
      _root.magazine = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;


      mybook=_root.books;
      mymagazine=_root.magazine;


      if(mybook>mymagazine)

      {mycolor.setRGB(0x462254);
      }

      else
      {mycolor.setRGB(0x45AF23);
      }


      book_txt.text = _root.books;
      magazine_txt.text = _root.magazine;


      } else {
      content = "file not loaded!";
      }
      }
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      xmlData.load("tienda.xml");


      And here is the XML code:

      <?xml version="1.0"?>

      <Tienda>
      <Libros>
      <id>Estant1</id>
      <Books>58</Books>
      <Magazine>334</Magazine>
      </Libros>
      </Tienda>

      You can see that magazine have more than books but the var mymagazine is getting only the first 2 digit (33). How can hay get all the numbers in my var?

      Here you can see the example of the file http://csform.com/xmltest/

      thanks you!
        • 1. Re: Get Numbers with xml and flash
          FlashTastic Level 1
          I can see all of the digits (58 and 334) on the test file that you posted. It's possible that when you were testing, the font was too large in your dynamic textbox, so only 2 numbers were displaying rather than 3. I tested the code and XML, and all of the values populate into the variables properly.

          Cheers,
          FlashTastic