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]