SlideShow Function not working (code by Scotty)

I have used a gallery code made by Scotty to implement a banner which starts a slideshow jpegs with a delay of 5 seconds once the first pic is loaded. There are a previous and a next button to fast forward to the preceding or following image. However once the previous or next button has been clicked it somehow inherits the delay of the other pic and goes to the next image without fully completing the 5 seconds.

Help is most appreciated and I hope Scotty himself could take a look at this :slight_smile:

Thanks again:hugegrin:

AS code:


var id, current;
var k = 0, p = 0;
var slide = 1;
var delay = 5000
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;
  }
  id = setInterval(preloadPic, 100);
 } else {
  content = "file not loaded!";
 }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
function preloadPic() {
 clearInterval(id);
 var con = picture.duplicateMovieClip("con"+k, 9984+k);
 con.loadMovie(image[p]);
 preloader._visible = 1;
 preloader.swapDepths(con.getDepth()+3);
 con._alpha = 0;
 var temp = _root.createEmptyMovieClip("temp"+k, 99+k);
 k++;
 temp.onEnterFrame = function() {
  var total = con.getBytesTotal();
  var loaded = con.getBytesLoaded();
  percent = Math.round(loaded/total*100);
  preloader.preload_bar._xscale = percent;
  if (con._width) {
   preloader._visible = 0;
   con.onEnterFrame = fadeIn;
   if (slide) {
    id = setInterval(nextImage, delay);
   }
   delete this.onEnterFrame;
  }
 };
}
MovieClip.prototype.fadeIn = function() {
 if (this._alpha<100) {
  current._alpha -= 10;
  this._alpha += 10;
 } else {
  current._visible = 0;
  current = this;
  delete this.onEnterFrame;
 }
};
function nextImage() {
 p<total-1 ? p++ : p=0;
 picture_num();
 preloadPic();
}
function prevImage() {
 p>0 ? p-- : p=total-1;
 picture_num();
 preloadPic();
}
function picture_num() {
 current_pos = p+1;
 pos_txt.text = current_pos+" / "+total;
}
previous_btn.onRelease = function() {
 slide = 0;
 prevImage();
};
next_btn.onRelease = function() {
 slide = 0;
 nextImage();
};
preloadPic();

XML file:


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
    <pic>
        <image>http://www.kirupa.com/developer/mx2004/pg/kresge.jpg</image>
    </pic>
    <pic>
        <image>http://www.kirupa.com/developer/mx2004/pg/medialab.jpg</image>
    </pic>
    <pic>
        <image>http://www.kirupa.com/developer/mx2004/pg/stata.jpg</image>
    </pic>
    <pic>
        <image>http://www.kirupa.com/developer/mx2004/pg/stata_lobby.jpg</image>
    </pic>
    <pic>
        <image>http://www.kirupa.com/developer/mx2004/pg/construction.jpg</image>
    </pic>
    <pic>
        <image>http://www.kirupa.com/developer/mx2004/pg/dome.jpg</image>
    </pic>
    <pic>
        <image>http://www.kirupa.com/developer/mx2004/pg/structure.jpg</image>
    </pic>
</images>