# Use a string variable to instantiate a variable

**URL:** <https://forum.kirupa.com/t/use-a-string-variable-to-instantiate-a-variable/2548>\
**Category:** flash\
**Created:** [June 11, 2002, 10:07am UTC](https://forum.kirupa.com/t/use-a-string-variable-to-instantiate-a-variable/2548 "2002-06-11T10:07:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2002, 10:07am UTC](https://forum.kirupa.com/t/use-a-string-variable-to-instantiate-a-variable/2548/1 "2002-06-11T10:07:13Z")

</div>

Hi… Im very new to Flash, so sorry if this is a stupid question.\rI 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.\rWhat I would like is something like this:\r\rvar strVarName;\r\r…\rstrVarName = “Var” + i;\rvar strVarName = new Array();\r…\r\rSo I would have n arrays called Var1, Var2, … Varn.\rIs there any way I can do this? \rThank you in advance for any help or comment

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2002, 2:14pm UTC](https://forum.kirupa.com/t/use-a-string-variable-to-instantiate-a-variable/2548/2 "2002-06-11T14:14:04Z")

</div>

lovin’ those while loops…

```auto
 \r\rfunction makeDemArrays(n,name){\r\r while(n--){\r\r _root[name + n] = [];\r\r }\r\r}

```

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