Photo Gallery Using XML and Flash

Dear Forum viewers,

I have a question regarding a tutorial on this website called [COLOR=#003366]Photo Gallery[/COLOR][FONT=Verdana][COLOR=#003366] Using XML and Flash. what i’ve tried to accomplish with this code is to add two little features. [/COLOR][/FONT]
[FONT=Verdana][COLOR=#003366]The first one: I want to load the picture movieclip with the size of the current Stage.size (picture._width = Stage.width; etc…)[/COLOR][/FONT]
[COLOR=#003366]But when i add this to the code, the text (desc_txt)from the picture is loaded but the picture is not. How should i code this. when openinge my webpage, the picture movieclip has the same size as my stage size. [/COLOR]
[COLOR=#003366]The second feature. i want the first image to be a random image. ive tried to add a variable k=math.floor((math.random) *i);[/COLOR]
[COLOR=#003366]and changed the line picture.loadMovie(image[k], 1);[/COLOR]
[COLOR=#003366]What happens is that, the first picture is indeed random, but when you press the refresh button, the text (desc_txt)of the picture changes(so it does reloads a random pic) but no more picture is displayed.[/COLOR]

[COLOR=#003366]Here you will find the original code, Hope someone can help me out here![/COLOR]
[COLOR=#003366]With Regards Jean.[/COLOR]

[COLOR=blue]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;
}[/COLOR]

[FONT=Verdana]

[/FONT]

Welcome to Kirupa. I maybe able to help on the first section ,but the section section I’d be a little hazy on.

Can I ask a question first? Is the stage size going to change? I.e stretch to fit a browser or a specific size say 640x480?

i’ve got a feeling you’ll need to add an

onClipEvent (load) 
//I'm a bit hazy on the rest off the top of my head

to the MC it loads the image into, then once its load you can specify the size it goes to…i have the code at home, i’ll post it later.

[COLOR=red]i hope to see your code! as you can see in the script it uses LoadMovie, how can we change that to an Clip Event?[/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=#ff0000]at home i also have a script that is using an clipevent for random images…maybe then this would work good too…[/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=#ff0000]we will see im looking forward to your post anyway![/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=#ff0000]cheers![/COLOR]