I am building a dynamic thumbnail gallery, where each image links to a fullsize version. (Sounds simple so far, but wait!) The thumbnails are created dynamically - an xml document provides the image path and description. I create a movie clip for each one on the fly, then load the appropriate image into it.
My problem is when I try to convert each movieclip into a button which loads the fullsize image. Each button loads the same image- the last one in my xml document. If I try placing “img*” inside the onRelease function, it comes up undefined. Here’s that bit of code:
var thisimage=img*;
eval(“thumbnail”+i).onRelease = function()
{
// do something
loadMovie (thisimage,_parent.emptyclip);
}
Can anyone see what I’m doing wrong? I’ve spent days on this and would be incredibly grateful for any help. The file is online here:
http://www.refindfurniture.com/refind.html (click on ‘portfolio’)
And here is all the actionscript:
var xpos=0;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
img = [];
description = [];
total = xmlNode.childNodes.length;
_global.total=total;
for (i=0; i<total; i++) {
img* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
thumbname=“thumbnail”+i;
j=createEmptyMovieClip(thumbname, getNextHighestDepth());
//this.createEmptyMovieClip(“outer_mc”, 1); // create one empty movie clip
j.createEmptyMovieClip(“inner_mc”, 1); // create another empty movie clip inside the previous
var tinybutton:MovieClip=j;
j.inner_mc.loadMovie(img*); // load the file inside the inner movie clip
// assign the onRelease() to the outer movie clip
j.me=“button”+i;
var thisimage=img*;
eval(“thumbnail”+i).onRelease = function()
{
// do something
loadMovie (thisimage,_parent.emptyclip);
}
j._x=(j._x + xpos);
xpos=(xpos + 170);
//end dubious code patch
}
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“portfolio_images.xml”);
activateButtons();
/////////////////////////////////////