2 Replies Latest reply on Sep 17, 2007 6:48 PM by RaGlitter

    converting a string into a variable name

    tikitin
      I have an array like:
      myArray=new Array();
      myArray.name_1=false;
      myArray.name_2=false;
      myArray.gnome_1=false;
      myArray.gnome_2=false;

      I also have dynamic textboxes called:
      name_1
      name_2
      gnome_1
      gnome_2

      I send a string and a number as variables and a string to be stored in the array and also written in a textbox:
      myFunctionCall("gnome",2, "dingelingeling");


      Now how do I convert the string "gnome" into a variable name? And write "dingelingeling" into dynamic textbox "gnome_2"?

      This obviously does not work:

      function myFunctionCall (myString, myNumber, mySecondString){
      myArray.myString+"_"+myNumber=mySecondString;
      _root.myString+"_"+myNumber.text=mySecondString;
      }