Xml photo gallery

First off let me say that this is a great and handy tutorial. Super useful and easy to follow. Thanks for the attention to detail.

Here is my question, is it possible to load the images xml files in the background? That is to say, while I am looking at the first images is it possible to keep loading the images later in the list (rather than waiting for me get there to load them).

If its possible, could somebody let me know how. Thanks in advance.

This is the code that I am working with:


function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		description = [];
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
			description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
		}
		firstImage();
	} else {
		content = "file not loaded!";
	}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
	if (Key.getCode() == Key.LEFT) {
		prevImage();
	} else if (Key.getCode() == Key.RIGHT) {
		nextImage();
	}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
	prevImage();
};
next_btn.onRelease = function() {
	nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
	filesize = picture.getBytesTotal();
	loaded = picture.getBytesLoaded();
	preloader._visible = true;
	if (loaded != filesize) {
		preloader.preload_bar._xscale = 100*loaded/filesize;
	} else {
		preloader._visible = false;
		if (picture._alpha<100) {
			picture._alpha += 10;
		}
	}
};
function nextImage() {
	if (p<(total-1)) {
		p++;
		if (loaded == filesize) {
			picture._alpha = 0;
			picture.loadMovie(image[p], 1);
			desc_txt.text = description[p].toUpperCase();
			picture_num();
		}
	}
}
function prevImage() {
	if (p>0) {
		p--;
		picture._alpha = 0;
		picture.loadMovie(image[p], 1);
		desc_txt.text = description[p].toUpperCase();
		picture_num();
	}
}
function firstImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[0], 1);
		desc_txt.text = description[0].toUpperCase();
		picture_num();
	}
}
function picture_num() {
	current_pos = p+1;
	pos_txt.text = current_pos+" / "+total;
}

Also, how would I go about loading and unloading various .xml files to the photogallery. Say, I have three different xml files with different groups of photos. What code would I attach to three different buttons to make them link to the different xml files. Thanks in advance.

Hi

Replying to ur question for loading three XML Files.

function selectFileName() {

myButton1.onPress() {
var fileName = xmlFile1;
}
myButton2.onPress() {
var fileName = xmlFile2;
}
myButton3.onPress() {
var fileName = xmlFile3;
}
return fileName;
}

myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = functionLoad();
myXML.load(selectFileName());


aShIsH

Thanks, it works perfectly. Any thoughts on loading the images in background?

I keep making the same boring flash banner at work cause people seem to lack imagination or just good taste :thumb: Its basicly just a gallery of 5-7 images fading in and out, no buttons. Im looking for a cooler way of doing this, hopefully with some scripting, but I myself dont know any scripting. Do you know how to load the images in and have the first one maybe wait for 3 seconds, then image number 2 fades over images one, then wait for 3 seconds for the next exciting thing to happen.

Any ideas boys and girls

Hi,

See help given in Flash for

MovieClipLoader.loadClip()

OR visit this link

http://livedocs.macromedia.com/flash/mx2004/main_7_2/00001577.html


aShIsH

bjarni, this is what you are looking for.
http://whatdoiknow.org/archives/001629.shtml

Ashish, I don’t quite know how to integrate the code I am now using and the MovieClipLoader.loadClip() function. Because I want the images to load in the background if that haven’t been called upon yet. That is to say, if the user is quickly cycling through the images, he will have to wait for each to preload with a preloader bar, but if a user is waiting to mull over an image, I would like to use that time to preload the rest of the images, so that when the user does click to see the next image it has already been loaded. Any thoughts would be great thanks.

Also, working with the code above, is it possible to, upon clicking for the next image, fade the current one out before preloading and fading the next image in?

Thanks. This is all a really big help and I appreciate it.

Any ideas? Help would really be fantastic.

Thanks in advance.

Ohh jesus, thanx man, thank you so much
:pleased: :pleased: :pleased: :pleased: :pleased: :pleased: :pleased:

Help, please. Any direction would be awesome.