Help with XML Picture Gallery

Hi Anyone,

I need help…yet again…with the XML picture gallery tutorial…I tried to make my own just by solely copying everything in the Finished fla and resizing it/colouring it to make it my own.
The only thing is, no pictures actually load except the ones used in the example…can anyone help?

Here is the file that I made (MX2004)
Soz I had to Zip it to make it OK to upload.

:kommie: I salute anyone who can help me :slight_smile:

Benji
BTW, the image I want to use is http://bgstorage.f2g.net/bg/p1.jpg, I made it bigger cause I thought the pxXpx made a difference, but alas it didn’t

Did you modify your images.xml file with the path to your new image?

:gm:

Yep

AHA! Thanks for that. I just checked the XML file and it had the image in but it had loads of extra space it didn’t need…Thanks.

Benji

Hmm…I can get one picture working but no other pictures work.

Benji

Does your XML file follow the same format that I wrote about in the tutorial? Also, if possible, could you post your XML file up here? That would make it easier for me to figure out what you may need to do.

Cheers!
Kirupa :kommie:

I think I’m ok now, but I’ll post it anyway.
There was one file that didn’t work but I don’t really mind about it.
I was displaying my pixel art.

[INDENT]<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?>
<images>
<pic>
<image>http://bgstorage.f2g.net/bg/p1.jpg</image>
<caption>iPod by Benji</caption>
</pic>
<pic>
<image>http://bgstorage.f2g.net/bg/p3.jpg</image>
<caption>Laptop by Benji</caption>
</pic>
<pic>
<image>http://bgstorage.f2g.net/bg/p4.jpg</image>
<caption>MP3 Player by Benji</caption>
</pic>
</images>

That was the code.
It’s not in order but its ok, also, is there any way of making the object centered because they all appear as close to the edge as possible for the picture…if you see what I mean.

Thanks,

Benji

I tested your XML file and FLA, and I was able to see all three pictures. If you want to adjust where your images are displayed, move the empty movie clip towards the center. If you check out the diagram in the tutorial, you will see that the the empty movie clip is basically a circle indicating where the movie clip should be :slight_smile:

OK, I was just wondering if there was any sort of code that made them centered but anyway, I don’t mind…

Thanks
Benji

Edit:
Is there any way of placing Link URLs in the XML file to make the picture into a button when you click on it?
This would be quite useful if you wanted…say…a gallery for Flash Animations and you just showed one frame of it and when you click the picture it takes you to the animation.

Benji

I’m having a problem with the prev. button… it ain’t working, but code seems fine …

What am i doing wrong ?


listen = new Object();
listen.onKeyDown = function() {

if (Key.getCode() == Key.LEFT) {

prevImage();

} else if (Key.getCode() == Key.RIGHT) {

nextImage();

}

};
Key.addListener(listen);

next_btn.onRelease = function() {

nextImage();

};

previous_btn.onRelease = function() {

prevImage();

};

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();
};

It should work with no spaces between the lines

Also have you named the button previous_btn

Nope … that doesn’t help

By the way, have you saved the file where the XML file is?

And I have changed the code for my code which is the same tutorial code but I know it works.
Paste this code into the actions frame:

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];
			picture_num();
		}
	}
}
function prevImage() {
	if (p>0) {
		p--;
		picture._alpha = 0;
		picture.loadMovie(image[p], 1);
		desc_txt.text = description[p];
		picture_num();
	}
}
function firstImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[0], 1);
		desc_txt.text = description[0];
		picture_num();
	}
}
function picture_num() {
	current_pos = p+1;
	pos_txt.text = current_pos+" / "+total;
}

Yes, the xml file is correct, cuz everything works… even the pre “arrow” on the keyboard works. Just the button doesn’t work…

I pasted your code into the action frame and i get the same thing … everything exept the prev. button works.

Seems something very strange :s

You’re not trying to use the previous button when it’s the first picture are you because that wouldn’t work.

Oh right…yeah I saw the arrow thing…I don’t know then…

nope … on pic 2 and 3 or more …

this is crazy … never had this happen before

I’m sorry I don’t know…

Thanks for the try anyway :wink:

I just find it strange that the prev. “arrow” works … but the prev. “button” doesn’t. It’s the same function …