Skip to main content
Participating Frequently
April 11, 2007
Question

XML gallery problem

  • April 11, 2007
  • 3 replies
  • 287 views
Hi,

Im using a pretty straight forward script to import images with thumbs via XML, Thats below:

myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
numimages = this.firstChild.childNodes.length;
spacing = 70;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes ;
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._y = i*spacing;
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() {
loader.loadMovie(this.main);
title_txt.text = this.title;
};
}
};
myPhoto.load("xmlphoto.xml");

Now all I need to do is create columns - what would be the best way!?

Thanks for reading,

Gavin

This topic has been closed for replies.

3 replies

Participating Frequently
April 13, 2007
Ah yeah of course!! It still dosn't work though! It's actually making me want to pop my eyes out of sockets with a teaspoon so I don't have to bother with it anymore. Any more suggestions?

PS Thanks for all the help anyway if not!

Gavin
Participating Frequently
April 12, 2007
Hi, Thanks for the speedy reply! I tried changing to the suggestion u made, as below but it didn't work! I think I did it wrong? Can you take a look please?

myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
numimages = this.firstChild.childNodes.length;
spacing = 70;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes ;
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._y = i*verticalSpacing*(i%2);
this.thumbHolder._x = i*horizontalSpacing*Math.floor(i/2);
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() {
loader.loadMovie(this.main);
title_txt.text = this.title;
};
}
};
myPhoto.load("xmlphoto.xml");


THANKS AGAIN!

Gavin
kglad
Community Expert
Community Expert
April 12, 2007
you don't have verticalSpacing and horizontalSpacing defined. and when displaying code in this forum use that attach code option. otherwise your [ i ] is interpreted as encoding for italic font. and that breaks your code and makes it difficult to read:

kglad
Community Expert
Community Expert
April 11, 2007
first, decide how many images (say n) in a column. second, assign the _x property of thumbHolder[ i ] by horizontalSpacing*Math.floor(i/n) and the _y property by verticalSpacing*(i%n)