1 Reply Latest reply on May 14, 2007 9:35 AM by Greg Dove

    global array so that array is not empty

      Hi ,
      I am pretty new at actionscript and flash in general. I have a question regarding global array.

      I am not sure how the global variables function but my test to create an array fails. Any idea how to edit so that the "arr" is not empty. The xml file is after the code

      _global.arr = new Array();
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;

      function loadXML(loaded) {

      if (loaded) {
      var person:Array = xmlData.firstChild.childNodes;
      for (var i:Number = 0; i < person.length; i++) {
      var node:XMLNode = person ;
      = node.childNodes[2].firstChild.nodeValue;
      } else {
      trace("file not loaded!");
      The xml file is here:
      <?xml version="1.0"?>

      <name>Thomas Edison</name>
      <comment>Inventor of many things such as the incandescent lightbulb.</comment>
      <name>Doug Engelbart</name>
      <comment>Invented the mouse at the Stanford Research Institute</comment>
        • 1. global array so that array is not empty
          Greg Dove Level 4
          I haven't tested it but there are a couple of things here I think:

          You're tracing _global.arr before the XML.onLoad has fired. Its empty when you trace it. Try tracing after the assignment of the value in the loadXML function.

          OOPS please ignore from this point forward.... your i array iterator is the reason - you should attach Code when posting in the forum because its interpreted as italic

          Your person array is the array of person nodes.

          so I think it should be:
          var node:XMLNode = person[a]
          //change the 'a' to an i (I didn't do it because I don't know how to avoid the formating in the forum without attaching code)

          in which case, if you uncomment the line with the arr.push it should be pushing the images on the array.