# Creating Arrays with Loadvars

**URL:** https://forum.kirupa.com/t/creating-arrays-with-loadvars/213518
**Category:** flash
**Created:** [January 20, 2007, 8:26am UTC](https://forum.kirupa.com/t/creating-arrays-with-loadvars/213518 "2007-01-20T08:26:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![karmakat](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/karmakat/32/476_2.png) [@karmakat](https://forum.kirupa.com/u/karmakat)
#### Post date: [January 20, 2007, 8:26am UTC](https://forum.kirupa.com/t/creating-arrays-with-loadvars/213518/1 "2007-01-20T08:26:52Z")

</div>

Hi,

I am trying to create an array from data in a text file.  
The text file data is like so:

&track1=Paradise Lake&track2=Somewhere Else&track3=Another Place

etc…

What I am trying to do is take all tracks and put them into an array so that i can attachmovies to the stage referencing them. So far if I try a:

```auto
trace[myVars.track1]

```

for instance, it spits out the correct variable into the output window.

But if I do a:

```auto
trace[myArray];

```

like in my AS at the bottom of this post, I get:

```auto
[object Object],[object Object],[object Object],[object Object]

```

Literally. Is this because I traced an array?

Am I even making the array correctly in my AS below? If I am, what’s next to be able to both trace the array so i can see if it’s working, and then how do I use that array to attachmovies with instances like track1, track2, etc. so that only as many tracks discovered in my text file by my AS become attached movies?

I hope that this is not to convoluted. I have spent many hours researching this, so excuse me if my google-finger missed a few logical searches.

here is my actionscript:

```auto

myVars = new LoadVars();
var myArray:Array = [];

myVars.onLoad = function(success:Boolean):Void {
   if (success) {
      var i:Number = 1;
   trace("loaded data");
      // repeat until all values have been read in
            while (this["track"+i] != undefined) {
               myArray.push({
   	       track:this["track"+i]
   		 
         });
         i++;
      }
       trackList();
   } else {
      trace('The information file could not be read');
   }
}

function trackList() {
   // code here to display the array, using myArray
   trace(myArray);
}
myVars.load("mytextfile.txt");

```

Thanks in advance for your advice.

- karmakat
