# Problems with my new XML Gallery

**URL:** https://forum.kirupa.com/t/problems-with-my-new-xml-gallery/263223
**Category:** open source
**Created:** [June 13, 2008, 1:58pm UTC](https://forum.kirupa.com/t/problems-with-my-new-xml-gallery/263223 "2008-06-13T13:58:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![SuperTramp](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@SuperTramp](https://forum.kirupa.com/u/SuperTramp)
#### Post date: [June 13, 2008, 1:58pm UTC](https://forum.kirupa.com/t/problems-with-my-new-xml-gallery/263223/1 "2008-06-13T13:58:00Z")

</div>

Hello Kirupa goers,

I basically had a gallery i was using for my website, but it was v simple and used embedded images for the thumbnails. i wanted to improve the gallery by using XML to load the thumbnails and main images.

I started experimenting with a few tutorials (im pretty new to XML) and got a very rough example working (sort of!). The problem is that some of the thumbnails arent loaded in the right order, and some of them are covering/overlapping other thumbnails.

My main AS code for the frame containing my 2 main movieclips (‘thumbLoader’ and ‘mainLoader’) is as follows:

\*_[FONT=Courier New]myPhoto = new XML();  
myPhoto.ignoreWhite = true;  
myPhoto.onLoad = function(success) {  
[COLOR=Silver]//portfolioTag = this.firstChild;[/COLOR]  
numimages = this.firstChild.childNodes.length;  
spacing = 85;  
yspacing = 65;  
colcount = 0;  
rowcount = 0;  
for (i=0; i \< numimages; i++) {  
this.picHolder = this.firstChild.childNodes_;  
this.thumbHolder = thumbLoader.createEmptyMovieClip(“thumbnail”+i, i);  
if (colcount \* spacing \> 180) {  
colcount = 0;  
rowcount++;  
this.thumbHolder.\_y += yspacing;  
this.thumbHolder.\_x = colcount;  
} else {  
if (rowcount \> 0) {  
this.thumbHolder.\_y = rowcount \* yspacing;  
}  
this.thumbHolder.\_x = colcount \* spacing;  
colcount++  
}  
this.thumbLoader = this.thumbHolder.createEmptyMovieClip(“thumbnail\_image”, 0);  
this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);  
this.thumbHolder.title = this.picHolder.attributes.title;  
this.thumbHolder.main = this.picHolder.attributes.main;  
this.thumbHolder.onRelease = function() {  
mainLoader.loadMovie(this.main);  
captionTxt.text = this.title;  
};  
}  
};  
myPhoto.load(“gallery.xml”);

[/FONT]\*\*[FONT=Courier New][FONT=Arial][COLOR=Black]My thumbLoader movieclip simply contains a shape where new empty movieclips are generated for each thumbnail. [/COLOR][/FONT]  
[/FONT]  
Here is an example of what ive got so far - note that thumbnails are not in the right order and only the ‘Personal’ section is accessible:  
[http://lauriedeandrivingschool.co.uk/ceh/testgal/xmlgallery.swf](http://lauriedeandrivingschool.co.uk/ceh/testgal/xmlgallery.swf)

(Sorry if this post is total garbage, im jus dam confused!)

ST

---

<div class="post-metadata">

### Author: ![nortago](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nortago/32/1240_2.png) [@nortago](https://forum.kirupa.com/u/nortago)
#### Post date: [June 13, 2008, 9:35pm UTC](https://forum.kirupa.com/t/problems-with-my-new-xml-gallery/263223/2 "2008-06-13T21:35:49Z")

</div>

This should really be in the help forums dude 🙂

But this should work…

```auto

myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
numimages = this.firstChild.childNodes.length;
var cols:Number = 3;
var spacer:Number = 5;
var thumbW:Number = 73;
var thumbH:Number = 55;
for (i=0; i < numimages; i++) {
this.picHolder = this.firstChild.childNodes*;
this.thumbHolder = thumbLoader.createEmptyMovieClip("thumbnail"+i, i);

this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
this.thumbLoader.loadMovie("http://lauriedeandrivingschool.co.uk/ceh/testgal/" + this.picHolder.attributes.thmb);
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;
this.thumbHolder._x = Number(thumbW + spacer) * Number(i % cols);
this.thumbHolder._y = Number(thumbH + spacer) * int(i / 3);

this.thumbHolder.onRelease = function() {
mainLoader.loadMovie("http://lauriedeandrivingschool.co.uk/ceh/testgal/" + this.main);
captionTxt.text = this.title;
};
}
};
myPhoto.load("http://lauriedeandrivingschool.co.uk/ceh/testgal/gallery.xml");

```

---

<div class="post-metadata">

### Author: ![SuperTramp](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@SuperTramp](https://forum.kirupa.com/u/SuperTramp)
#### Post date: [June 14, 2008, 1:28am UTC](https://forum.kirupa.com/t/problems-with-my-new-xml-gallery/263223/3 "2008-06-14T01:28:11Z")

</div>

yea sorry if its in the wrong place…

---

<div class="post-metadata">

### Author: ![SuperTramp](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@SuperTramp](https://forum.kirupa.com/u/SuperTramp)
#### Post date: [June 14, 2008, 1:33am UTC](https://forum.kirupa.com/t/problems-with-my-new-xml-gallery/263223/4 "2008-06-14T01:33:37Z")

</div>

Wow you just totally sorted it out, where was i going wrong??

thanks a lot anyway,

ST

---

<div class="post-metadata">

### Author: ![nortago](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nortago/32/1240_2.png) [@nortago](https://forum.kirupa.com/u/nortago)
#### Post date: [June 14, 2008, 10:54am UTC](https://forum.kirupa.com/t/problems-with-my-new-xml-gallery/263223/5 "2008-06-14T10:54:38Z")

</div>

I have no idea 🙂 - I just tested your as - and I was getting the same prob (although I suspect that the row count was getting confused) fortunately I’ve been working on a flash gallery the last few weeks, so I just ripped a bit of code for you 🙂
