1 Reply Latest reply on Jan 13, 2011 8:10 AM by snunicycler

    dynamic text wont show up in movie - as2

    snunicycler Level 3

      basically i have dynamic text fields that i have been trying to parse to an xml file. when i test the movie it does not work, all the fields are blank. but the info DOES show up in the output tab, so i know that it is making the connection.... it just doesnt show up in the movie. weird.

      here is my actionscript:

       

      var xml:XML=new XML();
      xml.ignoreWhite=true;
      xml.onLoad=parseXML;
      xml.load("popup.xml");

       

      function parseXML(){
      trace(this);
      {
          if (success)
          {
              var diagramNode=this.firstChild;
              var infoNode=diagramNode.childNodes[0];
              var nameNode=infoNode.childNodes[1];
              var ssnumberNode=infoNode.childNodes[2];
              var descriptionNode=infoNode.childNodes[3];
              var stockNode=infoNode.childNodes[4];
              var priceNode=infoNode.childNodes[5];
              var typeNode=infoNode.childNodes[6];
              var qtyNode=infoNode.childNodes[7];
               }
          else {
              content="oops, this stuff is confusing";
          }
      }
      }

       

       

      and here is my xml:

       

      <?xml version="1.0" encoding="utf-8"?>
      <diagram>
          <config>
          </config>
          <info>   
              <name>
                  Pedal Set With Toe Cage and Straps
              </name>

       

              <ssnumber>
                  P01LEM14139
              </ssnumber>

       

              <description>
                  Pedal set comes complete with both left and right pedals, toe cages and straps. Pedals have 9/16” shaft diameter where pedal threads into the crank arm.
              </description>

       

              <stock>
                  Item is in stock
              </stock>

       

              <price>
                  $15.95
              </price>

       

              <type>
                  EA
              </type>
             
              <qty>
                  1
              </qty>
             
             
          </items>   
      </diagram>

       

      thanks, -mitchell

        • 1. Re: dynamic text wont show up in movie - as2
          snunicycler Level 3

          ok, i must have been doing it wrong. i ended up following a different tutorial and i rewrote it this way and it works great now!

           

          function processXMLData(success)
          {
              if (success)
              {
                  var rootNode=this.firstChild;

           

                  var nameNode=findNode(rootNode, "name");
                  name=getValue(nameNode);
                 
                  var ssnumberNode=findNode(rootNode, "ssnumber");
                  ssnumber=getValue(ssnumberNode);
                 
                  var descriptionNode=findNode(rootNode, "description");
                  description=getValue(descriptionNode);
                 
                  var stockNode=findNode(rootNode, "stock");
                  stock=getValue(stockNode);
                 
                  var priceNode=findNode(rootNode, "price");
                  price=getValue(priceNode);
                 
                  var typeNode=findNode(rootNode, "type");
                  type=getValue(typeNode);
                 
                  var qtyNode=findNode(rootNode, "qty");
                  qty=getValue(qtyNode);
          }
              else
              {
                  content="oops, this is hard";
              }
          }

           

          function getValue(node)
          {
            if (node && node.firstChild)
                return node.firstChild.nodeValue;
            return "";
          }

           

          function findNode(node, nodeName)
          {
              if (node.nodeName==nodeName)
                  return node;
              for (var i=0; node.childNodes && i<node.childNodes.length; i++)
              {
                  var foundNode=findNode(node.childNodes[i], nodeName);
                  if (foundNode!=null)
                      return foundNode;
              }
              return null;
          }

           

          var xmlData=new XML();
          xmlData.ignoreWhite=true;
          xmlData.onLoad=processXMLData;
          xmlData.load("popup.xml");
          stop();