Creating Arrays with Loadvars

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:

trace[myVars.track1]

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

But if I do a:

trace[myArray];

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

[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:


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