# Dynamic Variable Name

**URL:** <https://forum.kirupa.com/t/dynamic-variable-name/281574>\
**Category:** flash\
**Created:** [February 10, 2009, 9:21pm UTC](https://forum.kirupa.com/t/dynamic-variable-name/281574 "2009-02-10T21:21:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mister\_B1](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@Mister\_B1](https://forum.kirupa.com/u/Mister_B1)\
**Post date:** [February 10, 2009, 9:21pm UTC](https://forum.kirupa.com/t/dynamic-variable-name/281574/1 "2009-02-10T21:21:15Z")

</div>

Suppose I want to dyanamically load 10 jpeg thumbnails. I have given them files names “image0.jpg”, “image1.jpg”, “image2.jpg”, image3.jpg" and so on.

Now, I might write out the code to do it ten times, like this:

var image0:loader = new Loader ();  
image0.load(new URLRequest ("images/image0.jpg);

var image1:loader = new Loader ();  
image1.load(new URLRequest (“images/image1.jpg”);

…yawn

But it would be much better if I could write out it out in a loop, and have the actionScript assign names to the variables. I don’t know actionscript so well, but I feel I want to have something like this:

var [name+i] :loader = new Loader();  
[name+i].load(new URLRequest (“images/”+[name+i]+".jpg");

Now I’ve just made that code up, but there is some logic in it, which I hope makes my question clearer.

I might be going entirely the wrong way about it all…
