Reputation: 10072
is it possible to create a new reference to an array by using it's varname ?
e.g.
private var _myArray:Array = new Array("a","m","d");
...
function getReference(_varName:String):void
{
trace(_varName)//_myArray
//ok, let's try to create the reference:
var _reference:Array = Class(getDefinitionByName(_varName)) as Array;
trace(_myArray.length)//3
trace(_reference.length)//0
}
...
?
Upvotes: 0
Views: 1412
Reputation: 1038
It's possible. I think the name of definition is not correct, you may use the full definition of the class like 'flash.display.xxx' or the class you defined. This is the reference http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getDefinitionByName%28%29
Upvotes: 0
Reputation: 301
You can use
private var _myArray:Array = new Array("A","B","C");
...
function getReference(_varName:String):void
{
trace(this[_varName].length)//3
}
...
Upvotes: 2