0

I've got a function that takes two strings as arguments, and I want to use these arguments to get the data held in associative arrays.

var myVar:Object = {};

myVar.value = 10;

function getStuff(v:String, vl:String){

//...

}

In this case, v = "myVar" and vl = "value".

How do I translate vinto the variable name 'myVar' and v1 into 'value' so that I can access the data?

1 Answer 1

1

Sorry if this won't work, for I can only test AS3 here, but please try this:

function getStuff(v:String, vl:String){
  return eval(v + "." + vl);
}

eventually

function getStuff(v:String, vl:String){
  return eval("_gobal." + v + "." + vl);
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.