1 Reply Latest reply on Aug 2, 2008 8:10 AM by kglad

    Problem - Creating Dynamic Var Name from XML

      Hi there.

      Here's my simple XML file:

      <?xml version="1.0" encoding="UTF-8"?>
      <var varName="speed" varValue="15" />
      <var varName="velocity" varValue="8" />
      <var varName="gravity" varValue="9" />

      I need to dynamically create a variable named (varName) and assign (varValue) as its value, accomplishing the following:

      speed = 15;
      velocity = 8;
      gravity = 9;

      However I am having trouble to evaluate the varName while creating the var within the loop:

      var XMLvars:XML = new XML();

      XMLvars.onLoad = function(success:Boolean) {
      if (success) {
      var getVars:Array = this.firstChild.childNodes;
      for (var i=0; i < getVars.length; i++) {
      // here's what I'm looking for:
      getVars .attributes.varName = getVars.attributes.varValue;

      XMLvars.ignoreWhite = true;

      Anyone to help????

      thanks in Advance,
      AunStudio team.