# Loading and using variables dynamically, need help

**URL:** <https://forum.kirupa.com/t/loading-and-using-variables-dynamically-need-help/278519>\
**Category:** flash\
**Created:** [December 31, 2008, 6:45pm UTC](https://forum.kirupa.com/t/loading-and-using-variables-dynamically-need-help/278519 "2008-12-31T18:45:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ag3nt42](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@ag3nt42](https://forum.kirupa.com/u/ag3nt42)\
**Post date:** [December 31, 2008, 6:45pm UTC](https://forum.kirupa.com/t/loading-and-using-variables-dynamically-need-help/278519/1 "2008-12-31T18:45:43Z")

</div>

Hi everyone,

I’m working on a project that requires me to load variables into my movie dynamically.

I’ve gotten to the point where I get the variables loaded into flash. But then I cannot use them dynamically once inside flash. I understand code pretty well But I am relatively new to actionscript.

The variables have to be used dynamically because I’ll never know how many variables there will be. Could be 1 could be zero, could even be 1000.

So say my loaded variable var.txt had this line in it.

```auto
File1=Pages/PageData/Page1/Downloads/SomeTextFile.rar&File2=Pages/PageData/Page1/Downloads/SomeTextFile1.rar&File3=Pages/PageData/Page1/Downloads/SomeTextFile10.rar&File4=Pages/PageData/Page1/Downloads/SomeTextFile11.rar&File5=Pages/PageData/Page1/Downloads/SomeTextFile2.zip&File6=Pages/PageData/Page1/Downloads/SomeTextFile3.rar&File7=Pages/PageData/Page1/Downloads/SomeTextFile4.rar&File8=Pages/PageData/Page1/Downloads/SomeTextFile5.rar&File9=Pages/PageData/Page1/Downloads/SomeTextFile6.rar&File10=Pages/PageData/Page1/Downloads/SomeTextFile7.rar&File11=Pages/PageData/Page1/Downloads/SomeTextFile8.rar&File12=Pages/PageData/Page1/Downloads/SomeTextFile9.rar&Img1=Pages/PageData/Page1/Imgs/Copy (10) of objectBack.png&Img2=Pages/PageData/Page1/Imgs/Copy (11) of objectBack.png&Img3=Pages/PageData/Page1/Imgs/Copy (2) of objectBack.png&Img4=Pages/PageData/Page1/Imgs/Copy (3) of objectBack.png&Img5=Pages/PageData/Page1/Imgs/Copy (4) of objectBack.png&Img6=Pages/PageData/Page1/Imgs/Copy (5) of objectBack.png&Img7=Pages/PageData/Page1/Imgs/Copy (6) of objectBack.png&Img8=Pages/PageData/Page1/Imgs/Copy (7) of objectBack.png&Img9=Pages/PageData/Page1/Imgs/Copy (8) of objectBack.png&Img10=Pages/PageData/Page1/Imgs/Copy (9) of objectBack.png&Img11=Pages/PageData/Page1/Imgs/Copy of objectBack.png&Img12=Pages/PageData/Page1/Imgs/objectBack.png&NumFiles=12&NumImgs=12

```

How then could I use these variables in flash without knowing how many there will be.

For example…

I know that I can target a variable statically like this:

```auto
 
_root.LoadedContent_mc.LoadedContent2_mc.Page1_mc.MyFiles.File1;

```

But if there is more then one file flash does not know how to handle it.

If i try this I get the value of “MyFiles” with the number i='s smacked on the end of it:

```auto
 
var i:Number = 1;
var FilePaths:Array = Array();
for (x in _root.LoadedContent_mc.LoadedContent2_mc.Page1_mc.MyFiles)
{
FilePaths.push(_root.LoadedContent_mc.LoadedContent2_mc.Page1_mc.MyFiles.File+i);
i++;
}

```

this is a simplified version of what I’m doing… I actually have a bunch of if statements to weed out the onload events and variables I don’t use as a file path.

What would make sense is if I could target the variables like so

```auto
_root.LoadedContent_mc.LoadedContent2_mc.Page1_mc.MyFiles*;

```

“i” equalling the current file name 1-?

So any help or suggestions of an alternate way are appreciated…

thanks again.
