[F8-AS2]Dynamic array names in a for statement

Hi all, I have been a long time ‘lurker’ and have made great use of the site and information on it. But now I find myself in a bit of a jam which I am not able to find a way around myself (in a satisfactory way, atleast).

First I will explain what I’m trying to do, then I’ll post the code, and hopefully after that somebody will be kind enough to point out my mistake or a work around.

I am making an XML multiple-gallery flash site for a client. The chunk of code I am having trouble with is populating the thumbmails section of the site with all the pictures in all the galleries. The image paths are brought in and stored in an array - one array for each gallery’s image paths. The problem is that when I try to cycle through all the images to put them into movie clips (using a fore statement) I am having trouble dynamically addressing the arrays. **More specifically, flash interprets them as strings, and does not evaluate the variables in them. **I have tried all mess of things using eval, to no luck. So I will post up the code, and hopefully one of you geniuses will make me look dumb :slight_smile:

function images(i){
 var temp:Number = eval("g"+i+"im.length");
 for (var r:Number=1; r<=temp; r++){
  eval("this.thumbHolder_mc.gallery"+i+"_mc").createEmptyMovieClip("thumb"+r+"_mc", 3550+r); 
  //doesn't work, but i would really like it to :)
  loadMovie("g"+i+"im["+(r-1)+"]", eval("this.thumbHolder_mc.gallery"+1+"_mc.thumb"+r+"_mc")
  //works, but not dyamic as gallery number is coded by hand.
  loadMovie(g1im[(r-1)], eval("this.thumbHolder_mc.gallery"+1+"_mc.thumb"+r+"_mc"));

The argument images() takes is the gallery number (from another function). I have tried using eval() and trace to see what the problem is. Basically I can make it output the correct STRINGS, but flash will not convert the variables in the strings! So in the URL (first arg) of loadMovie it is seeing something like “g2im[3]” as a string, and not evaluating it to the value at index 4 of that array.

I hope all that made sense, help would be very much appreciated.