1 Reply Latest reply on Jan 5, 2008 6:31 AM by czflex

    convert string to a variable?

    czflex Level 1
      Hello, I cannot figure out if it is possible to get a variable value, if I know the variable name, but I have stored it in a String; Imagine I have a class (pseudo code)

      class CL1 {
      i :integer = 10;
      myName: String = "Jack";
      }

      and I also have a String;

      var str:String = "myName";

      So if I want to get the "Jack" string, I just can write CL1.myName, but if I only have a CL1 (and don't know the structure of the class), but I know that inside the class is a property of a name (the name is stored in 'str'), can I somehow get the property of the class?

      I need it, because when I use datagrids, there is the same situation, in dataField is a name of the property, and I want to get the value of a dataProvider explicitelly....

      Thank you for reading this :-)
        • 1. Re: convert string to a variable?
          czflex Level 1
          I am sorry, but sometimes, just when I set the new thread, I find out the solution...., so it's easy, I can use for example....

          this["myVariable"]

          ... to get a value of a variable myVariable, or....

          var mynewstring:String =:CL1[ str ];

          to get the "Jack" String from the example above....

          Thanks anyway.