I’ve gone through the forum over and over again to find a solution to my problem… and I’ve come up unlucky. Unless I’ve overlooked something, in which case I still need help.
I used the tutorial for Photo Gallery Using XML and Flash on the site. I originally used the code for the slideshow, but the need for back, forward, and pause buttons was called for. Then, I needed the slideshow to load the first image randomly from the XML file, which it does. However, I’d like to code it so that it continues in a non-random order from the current picture it is on. Say, if it randomly loads the 8th image in a set of 20, I want the slideshow to continue to image 9 in the xml file, so on and so forth. Is this possible?
Here is my actionscript:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
}
randomImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
controls.play_btn._visible = 0;
p = 0;
delay = 7000;
controls.pause_btn.onRelease = function() {
clearInterval(myInterval);
controls.pause_btn._visible = 0;
controls.play_btn._visible = 100;
};
controls.play_btn.onRelease = function() {
myInterval = setInterval(pause_slideshow, delay);
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
};
controls.previous_btn.onRelease = function() {
if (p == 0) {
p = total;
lastImage();
}else{
prevImage();
}
if (p == (total-1)) {
prevImage();
}
};
controls.next_btn.onRelease = function() {
//nextImage();
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
};
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() {
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
if (p<(total-1)) {
p++;
if (loaded == filesize) {
clearInterval(myInterval);
picture._alpha = 0;
picture.loadMovie(image[p], 1);
slideshow();
}
}
}
function prevImage() {
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
if (p>0) {
p--;
clearInterval(myInterval);
picture._alpha = 0;
picture.loadMovie(image[p], 1);
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
slideshow();
}
}
function lastImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[total-1], 1);
slideshow();
}
}
function randomImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[random(total)], 1);
}
slideshow();
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
}
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}