PDA

View Full Version : Use a string variable to instantiate a variable



pepgomez
June 11th, 2002, 06:07 AM
Hi... Im very new to Flash, so sorry if this is a stupid question.
I would like to dinamically create array variables, depending on a XML file. The problem I have is that I don't know how to create them dinamically using a name I have constructed into a string variable.
What I would like is something like this:

var strVarName;

...
strVarName = "Var" + i;
var strVarName = new Array();
...

So I would have n arrays called Var1, Var2, ... Varn.
Is there any way I can do this?
Thank you in advance for any help or comment

suprabeener
June 11th, 2002, 10:14 AM
lovin' those while loops...


function makeDemArrays(n,name){

while(n--){

_root[name + n] = [];

}

}
n is the number of arrays to create. name should be a string (in quotes).