Dynamically loaded clips with external images & specific functions

Hi fellow flash developers :hr:

I’m trying to build a little function that loads some variables from an online PHP file, where I get the number of existing elements, the correspoding thumbnails and the associated text for each. This elements are to be placed horizontally 120pix right after each other. For this, I chose to use a “for in” loop, that executes the number of times equivalent to the number of elements retrieved from the variable in the PHP file the SWF connects to.

Unfortunately the PHP file still doesn’t have the paths to the thumbnails set in any variable, so for purposes of testing I am loading these thumbnails from the hard disk. They are in the SWF’s folder.

The connection with the PHP is working fine, I am able to get the number of elements in it. The address if you want to check the variables, is http://www.imaginando.net/resin/traction.php .

So, in a more synthetic way, how do I get these images to appear on each corresponding clip I create, and how do I make them have a specific .onRelease function?

Going through the script helps to understand :book:

//declare the thumbnails’s pictures array
releasesArray = new Array(“RSI001small.gif”, “RSI002small.gif”, “RSI003small.gif”, “RSI004small.gif”);

//load the number of elements from the PHP
loadReleases = new LoadVars();
loadReleases.load(“http://www.imaginando.net/resin/traction.php”);
loadReleases.onLoad = function() {

    //the number of elements is the variable ntractions
_global.numberOfElements =  this.ntractions;

trace(numberOfElements); //this shows 10 in the output panel, there are 10 elements

    //let this loop 10 times then.
for (i=0; i<numberOfElements; i++) {

    //the next line of code is my attempt to set the "currentTractionImage" to "RSI001small.gif", doesn't seem to work

currentTractionImage = releasesArray*;
trace(currentTractionImage); //this unfortunately outputs underfined

    //get the button instance from the library (linkage id "traction_element", containing an MC with the instance name "holder_mc" where I would like to place an image from the SWFs folder, more precisely the actual * element of releasesArray:
var currentTractionItem = _root.attachMovie('traction_element', 'traction_element'+i, i);

    //place the newly created item 120pix to the right
currentTractionItem._x += i*120;

    //here I try to dinamically load the external GIF but the requested releasesArray's value is not retrieved
currentTractionItem.holder_mc.loadMovie(releasesArray*);

   //the following command tests the button's activity, and works

//> //how do I apply a specific action for each?
currentTractionItem.onRelease = function() {
trace(“button pressed”);
}

    //yet another yellow attempt to reach releasesArray's content
var imagetoLoad = ["RSI00"+i+"small.gif"];
trace("imageToLoad = " + imageToLoad); //outputs undefined :(
}

}

stop();

so… that’s my frustrated attempt to do it, and what fails is listed in the code’s comments. If you see any mistake or any suggestion to make, I thank you in advance!