# Dynamic thumbnails from xml

**URL:** <https://forum.kirupa.com/t/dynamic-thumbnails-from-xml/227408>\
**Category:** Uncategorized\
**Created:** [May 30, 2007, 1:40am UTC](https://forum.kirupa.com/t/dynamic-thumbnails-from-xml/227408 "2007-05-30T01:40:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spaceapple](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@spaceapple](https://forum.kirupa.com/u/spaceapple)\
**Post date:** [May 30, 2007, 1:40am UTC](https://forum.kirupa.com/t/dynamic-thumbnails-from-xml/227408/1 "2007-05-30T01:40:03Z")

</div>

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](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](https://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();

/////////////////////////////////////
