Calling a variable given its string name
var myvar = "this is the value of myvar"; var notMyvar = "this is some other variable"; var thirdVar = "this is some third var"; var nameOfVarToCall = "myvar"; //print the content of the var name specified, in this case "myvar"
I have a string which contains the name of a variable I need. What I want to do is find out the name of var (in this case "myvar") and use the name to access the value of the var (in this case just print out the value). Is this feature available in Actionscript. I know it's available in PHP and can come in very handy.
You can access any property of the object specified as string by using  operator.
// assuming nameOfVarToCall is a member of this object. trace(this[nameOfVarToCall]); // if nameOfVarToCall is member of object myObj trace(myObj[nameOfVarToCall]);