3 Replies Latest reply on Oct 20, 2013 5:09 AM by Ned Murphy

    Problem with pushing xml child attribute to an empty array

    rjgalido

      Hi guys,

       

      I have another problem with putting, or shall I say, pushing data from xml to an empty array I previously declared.

       

      During the xml_mc.onload, I can see the data, but after that, it becomes undefined.

       

      It seems like I could not find the solution on the net as well. I suspect it is not possible, but I wont give up.

       

      Please help me.

       

      Thanks.

       

      This is the code sample:

       

       

      var myarray=new Array();

       

      var xml1:XML = new XML();

      xml1.ignoreWhite=true;

       

      xml1.onLoad = function(success:Boolean){

       

       

                if(success){

       

            var nodes = this.firstChild.childNodes;

            

                          for (i=0; i<nodes.length; i++){

                     myarray[i]=nodes[i].attributes.name;

                          }

       

               text1.text=myarray[2];  // *******************************to check if the attribute "name" is visible

       

                } else {

                          trace("Could not load XML");

                }

      }

       

       

      xml1.load("icons.xml");

       

       

      text1.text=myarray[2]; // *******************************I commented the first  text to try to view again, and result was UNDEFINED..........

       

       

       

       

       

      the xml would look like this:

       

       

      icons.xml

       

       

      <icons>

           <icon name="icon1" />

           <icon name="icon2" />

           <icon name="icon3" />

           <icon name="icon4" />

      </icons>

       

       

      thanks