# Please Help me with an XML gallery code problem

**URL:** <https://forum.kirupa.com/t/please-help-me-with-an-xml-gallery-code-problem/170417>\
**Category:** flash\
**Created:** [November 25, 2005, 8:03pm UTC](https://forum.kirupa.com/t/please-help-me-with-an-xml-gallery-code-problem/170417 "2005-11-25T20:03:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![victord\_21](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/victord_21/32/1960_2.png) [@victord\_21](https://forum.kirupa.com/u/victord_21)\
**Post date:** [November 25, 2005, 8:03pm UTC](https://forum.kirupa.com/t/please-help-me-with-an-xml-gallery-code-problem/170417/1 "2005-11-25T20:03:55Z")

</div>

Hi. I need some help on a XML gallery code…The code is kindda’ finished…well, kindda…The gallery is set to load like this:

It reads the XML to store the number of thumbnails that I want to group in 3 rows and stacks of 6 (subgalleries-movieclip from the library)…so I calculate the number of subgalleries.

Then I load the thumbnails in different instances of a movieclip from the library which I want to place in the subgallery using a function with [color=darkorange]attachMovie [/color][color=black]and [color=darkorange]if…else[/color] with different conditions.[/color]

The problem is that I can’t get the attachMovie sintax right on function [color=#008000]thumbnails\_fn[/color]…It doesn’t attach the movieclips from the library if I want to attach them to the subgallery…it works if I load them to the scene… :h: I can’t figure out what I’m doing wrong.

Here’s the code that I use:

[color=green]function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
thumbnails = [];  
albume = [];  
total = xmlNode.childNodes.length;  
if(total%6==0){  
\_root.r=Math.round(total/6);  
}else{  
\_root.r=Math.round((total/6)+1);  
}  
for(j=0; j\<\_root.r; j++){  
albums(j);  
}  
a1=0;  
for (a2=0; a2\<\_root.r; a2++) {  
CA=albume[a2];  
trace(CA);  
for (i=a1; i\<a1+6; i++) {  
if(i\<total){  
thumbnails\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
thumbnails\_fn(i,CA);  
}  
}  
a1+=6;  
}  
}else {  
content = “file not loaded!”;  
}

}[/color]  
[color=green]xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“projects.xml”);[/color]  
[color=green][/color]  
[color=green]/////////////////////Thumbnail Generator Code//////////////[/color]

[color=green]function thumbnails\_fn(k,CAlbum){  
movie=this.CAlbum.attachMovie(“obj”, “obj”+k, 500+k);  
if(k\>0){  
if((k)%3==0){  
movie.\_x=0;  
movie.\_y += thisY+80;  
}else{  
movie.\_x += thisX+120;  
movie.\_y = thisY;  
}  
}else{  
movie.\_x=0;  
movie.\_y=0;  
}  
thisX=movie.\_x;  
thisY=movie.\_y;  
movie.thumbnail.loadMovie(thumbnails[k],movie.thumbnail.getNextHighestDepth());  
}[/color]

[color=green]/////////////////Album Generator Code//////////////[/color]

[color=green]function albums(h){  
albumMC=this.attachMovie(“album”, “album”+h, 50+h);  
albume[h]= “album”+h;  
albumMC.\_x=0;  
albumMC.\_y += thisYalbum+200;  
thisYalbum=albumMC.\_y;  
}[/color]  
[color=#008000][/color]  
[color=black]Really appreciate any help I can get![/color]
