any way of doing this is as3?
for example, if I have a var dog:String
, how can I get \"dog\" out of that variable?
Looking into reflection to d
In your example I don't think there is a way to retrieve "dog" as a String.
However, if dog
is a property of a dynamic
Object, then you could use a function like this:
function getVarName(subject:*, value:*):String
{
for(var i:String in subject)
{
if(subject[i] == value) return i;
}
return "";
}
This function can work in a scenario like this:
var holder:Object = {
dog: "some awesome dog"
}
trace(getVarName(holder, "some awesome dog")); // dog