Answered
change string to variable (sort of)
Hi. I am making a game in flash which requires lots of
similar functions, such as
function getSomeNumber():Number{
return number;
}
I was wondering if i could generalize this by doing the following. take a parameter of string defining the name of the variable. i then want to change this string to the name of the variable so that i can output the value of the variable. a bit like this
function getSomeNumber(nameOfVar:String):Number{
//somehow use string to find out variable name and return value of variable
return unknown;
}
hope this makes sense.
trigger2160
function getSomeNumber():Number{
return number;
}
I was wondering if i could generalize this by doing the following. take a parameter of string defining the name of the variable. i then want to change this string to the name of the variable so that i can output the value of the variable. a bit like this
function getSomeNumber(nameOfVar:String):Number{
//somehow use string to find out variable name and return value of variable
return unknown;
}
hope this makes sense.
trigger2160