0 Replies Latest reply on Jun 20, 2006 12:46 AM by Punch Creative

    Using function parameter as name for array

    Punch Creative
      I'd like to use a parameter in a function for naming an array which is created in that function
      if i choose the name for the array other than the parameter name the function works properly
      the reason why i want this is that with the function i can load different xml files and name the arrays build by the function as the xml file, below is the function

      function laadXML(xml_bestand) {
      var xmlData:XML = new XML();
      xmlData.ignoreWhite = true;
      xmlData.load("xml/" + xml_bestand + ".xml");
      xmlData.onLoad = function(succes) {
      if (succes) {
      this.xml_bestand = new Array();
      var totItems:Number = this.firstChild.childNodes.length;
      for (i=0; i<totItems; i++) {
      this.xml_bestand = new Array();
      var subItem:Number = this.firstChild.childNodes[0].childNodes.length;
      for (k=0; k<subItem; k++) {
      var benamingItem:String = this.firstChild.childNodes[0].childNodes[k].nodeName;
      var waardeItem:String = this.firstChild.childNodes
      .childNodes[k].childNodes[0].nodeValue;
      trace(benamingItem + " " + waardeItem);
      this.xml_bestand [k] = waardeItem;
      }
      }
      onXMLParsed()
      } else {
      trace ("XML laadt");
      }
      }
      }