# Getting variables out of a For loop!

**URL:** <https://forum.kirupa.com/t/getting-variables-out-of-a-for-loop/317779>\
**Category:** flash\
**Created:** [January 3, 2011, 1:25am UTC](https://forum.kirupa.com/t/getting-variables-out-of-a-for-loop/317779 "2011-01-03T01:25:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vbkun](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vbkun](https://forum.kirupa.com/u/vbkun)\
**Post date:** [January 3, 2011, 1:25am UTC](https://forum.kirupa.com/t/getting-variables-out-of-a-for-loop/317779/1 "2011-01-03T01:25:33Z")

</div>

hi people!  
=D

i’m trying to use a for loop to generate for me a set of vars, but it’s not really working out. =.=.

I’m loading the image file names from a xml, and i want that the for loop create vars like “fotoToLoad0, fotoToLoad1 …” and load the filename within.

I guessed i had to use the eval command, but as far as my ignorance sees it, when it is used, the eval makes a variable reffer to another and not fill it’s value. (I guess i’m wrong thou).

Here’s what i’ve tried so far:

```auto
	for (i=0; i< totalNodes; i++){
	var fotoEnd = imagesXML.firstChild.childNodes*.firstChild.firstChild;
	var fotoTemp = eval ('fotoToLoad'+i);
	fotoTemp = fotoEnd;

```

That’s quite not working thou =(. If i try used 'fotoToLoad1" for example, in a text box it just returns undefined =(.

Thanks in advance!
