Converting string text to useable code

Hey all,
I’ve been working on an image gallery, and are now at the stage of making the “select your gallery” page, and the transition into the gallery selected.
You can see how this looks like here:

However, using XML data to load the images, i need to have a way to specify which XML gallery will be loaded. This is how i’ve structured it:

thumbnail_mc.gallerynumber = currentimage.attributes.number;

thumbnail_mc.onRelease = function(){
var galleryselected = int(this.gallerynumber);
        var siblingnumber = "";
        for (var o = 1; o < galleryselected; o++) {
        var siblingnumber = siblingnumber + ".nextSibling";
    var galleryselection = "gallery_xml.firstChild" + siblingnumber + ".childNodes";
    var subGalleryimages = galleryselection;

The XML data has the following structure:

name = something
thumb = link
number = 1>

name = something
thumb = link
image = link
description = something>


name = somethingelse
thumb = link
number = 2>




The number attribute of the galleries (1,2,3,etc) is used to define how many time the “.nextSibling” code is used, to indicate which gallery to access for the childNodes (the images).

When using:

trace ("gallery_xml.firstChild" + siblingnumber + ".childNodes");

When clicking on the second thumbnail (second gallery), I get displayed:


which is right, but it wont work with the code, and the correct gallery wont load.
Attached is a txt with the entire actionscript.

Any ideas on how to convert this string into a piece of code which flash can then use to locate the right gallery in the XML?

many thanks in advance!

regards, Frederik