Updated xml slideshow code - final tweak needed

hi everyone.

i have updated the xml photo gallery with slideshow.

  • I now have a stop slideshow button.
  • A slideshow button simply calls nextImage() and starts the slideshow again.
  • I also have a previous and next buttons that don’t start the slideshow function.

Here is my question. when using the slideshow or the next button it gets to the last image and stops. Can anyone show me the ‘if’ statements that would go back to image1 and allow both of these functions to continue.

Below is the code i have. i also managed to get the images to pop into a new window, centred, with the window determined by the image dimensions. I am chuffed about that but am just stuck on the ‘if’ statements.

Cheers for any help.


var_img = “”;
delay = 6000;
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) {
delay = 6000;
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
delay = 6000;
}
};
Key.addListener(listen);

previous_btn.onRelease = function() {
prevImage();
};

next_btn.onRelease = function() {
nextImage1();
};
stop_btn.onRelease = function() {
clearInterval(myInterval);
};

slideshow_btn.onRelease = function() {
nextImage();
};

_root.openWinCentre = function(url, thewin, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {
var bo_var = _root.var_img;
//CHANGE
trace(bo_var);
var bo_img = bo_var.substr(0, -10);
trace(bo_img);
url = bo_img+"_big.htm";
trace(url);
//myImage = bo_img+"_big.jpg";
getURL(“javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open(’”+url+"’,‘thewin’,’"+“width=”+w+",height="+h+",toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",top=’+((screen.height/2)-("+h/2+"))+’,left=’+((screen.width/2)-("+w/2+"))+’"+"’)}else{myWin.focus();};void(0);");
};

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 nextImage1() {
clearInterval(myInterval);
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
_root.var_img = image[p];
}
}
}

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();
_root.var_img = image[p];
slideshow();
}
}
}

function prevImage() {
if (p>0) {
p–;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
_root.var_img = image[p];
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
_root.var_img = image[p];
slideshow();
}
}

function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" of "+total;
}

function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}

instead of this.

slideshow_btn.onRelease = function() {
nextImage();
};

try this

slideshow_btn.onRelease = function() {
slideshow();
};

I tried the XML Photogallery - Slideshow and love it! Sweet Code. Anyone know how to add links to the photos in the XML files. I’m building a portfolio and need to link to several different pages from different slides.