Problems with my new XML Gallery

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

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

ST

This should really be in the help forums dude :slight_smile:

But this should work…


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");



yea sorry if its in the wrong place…

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

thanks a lot anyway,

ST

I have no idea :slight_smile: - 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 :slight_smile: