3 Replies Latest reply on Mar 9, 2010 11:43 AM by kglad

    AS 2: Using an XML object to retreive a static XML file

    kjnieland

      I’m working on learning how to bring  XML info into Flash. Eventually I’m trying to pull a bunch of data about  Interstate 80 drug and cash stops for an interactive project to go with a big  centerpiece story for the newspaper I work for.

       

      I’ve been through a Lynda.com tutorial  three times now. I made a dataset, bound it to a datagrid and attached the datagrid to the xml file. When I run a trace, I can see in the output window that the XML is being pulled in. But I must be doing something wrong nothing is being displayed in the datagrid. It should bring in the first three items in the  code: ‘yr, date, and when’ into their categories in the  grid, but it's just blank.

       

      Here’s the code in flash:

       

      var myXML:XML = new  XML();

      myXML.ignoreWhite =  true;

      myXML.onLoad =  function(success) {

                   if(success) {

                               for (var x=0;x<this.firstChild.childNodes.length;x++)  {

                               var i80Node:XMLNode =  this.firstChild.childNodes[x];

                               i80_ds.addItem({yr:i80Node.attributes.yr,

                                                                               date:i80Node.attributes.date,

                                                                               when:i80Node.attributes.when });

                               }

                  } else  {

                               //Throw error here

                   }

      }

      myXML.load("http://www.huskerextra.com/resources/newsroom/2010/mar/i80katietest.xml");

       

      Here's the XML data:


      <?xml version="1.0"?>
      <results_packet>
        <rec yr="2009" date="9.9.08" when="3:47 p.m." />
        
      </results_packet>

       

      If you have any ideas, it’d be much  appreciated, I have been trying to figure this out for hours.

       

      I'm new to this XML to Flash thing. Mostly what I do is just make buttons and animations, so thanks so much for any  help!

       

      KJNieland