# Help with XML Picture Gallery

**URL:** <https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953>\
**Category:** flash\
**Created:** [September 11, 2004, 7:56pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953 "2004-09-11T19:56:04Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 7:56pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/1 "2004-09-11T19:56:04Z")

</div>

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 🙂

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 8:05pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/2 "2004-09-11T20:05:13Z")

</div>

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

:gm:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 8:05pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/3 "2004-09-11T20:05:37Z")

</div>

Yep

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 8:09pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/4 "2004-09-11T20:09:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 8:21pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/5 "2004-09-11T20:21:24Z")

</div>

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

Benji

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 8:40pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/6 "2004-09-11T20:40:57Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 8:45pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/7 "2004-09-11T20:45:25Z")

</div>

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](http://bgstorage.f2g.net/bg/p1.jpg)\</image\>  
\<caption\>iPod by Benji\</caption\>  
\</pic\>  
\<pic\>  
\<image\>[http://bgstorage.f2g.net/bg/p3.jpg](http://bgstorage.f2g.net/bg/p3.jpg)\</image\>  
\<caption\>Laptop by Benji\</caption\>  
\</pic\>  
\<pic\>  
\<image\>[http://bgstorage.f2g.net/bg/p4.jpg](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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2004, 9:44pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/8 "2004-09-11T21:44:38Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 9:10am UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/9 "2004-09-12T09:10:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:23pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/10 "2004-09-12T15:23:52Z")

</div>

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

};

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:26pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/11 "2004-09-12T15:26:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:31pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/12 "2004-09-12T15:31:14Z")

</div>

> [@benji2004](#):
>
> It should work with no spaces between the lines
> 
> Also have you named the button previous\_btn

Nope … that doesn’t help

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:37pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/13 "2004-09-12T15:37:26Z")

</div>

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:

```auto
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;
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:48pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/14 "2004-09-12T15:48:21Z")

</div>

> [@benji2004](#):
>
> 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:

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:51pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/15 "2004-09-12T15:51:10Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:52pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/16 "2004-09-12T15:52:36Z")

</div>

> [@benji2004](#):
>
> You’re not trying to use the previous button when it’s the first picture are you because that wouldn’t work.

nope … on pic 2 and 3 or more …

this is crazy … never had this happen before

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:54pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/17 "2004-09-12T15:54:56Z")

</div>

I’m sorry I don’t know…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 12, 2004, 3:57pm UTC](https://forum.kirupa.com/t/help-with-xml-picture-gallery/63953/18 "2004-09-12T15:57:30Z")

</div>

> [@benji2004](#):
>
> I’m sorry I don’t know…

Thanks for the try anyway 😉

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