# Xml slideshow- setinterval() counting pre-loading time of images

**URL:** https://forum.kirupa.com/t/xml-slideshow-setinterval-counting-pre-loading-time-of-images/212367
**Category:** Uncategorized
**Created:** [January 10, 2007, 4:05pm UTC](https://forum.kirupa.com/t/xml-slideshow-setinterval-counting-pre-loading-time-of-images/212367 "2007-01-10T16:05:12Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dipuchandran](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@dipuchandran](https://forum.kirupa.com/u/dipuchandran)
#### Post date: [January 10, 2007, 4:05pm UTC](https://forum.kirupa.com/t/xml-slideshow-setinterval-counting-pre-loading-time-of-images/212367/1 "2007-01-10T16:05:12Z")

</div>

I was working on my portfolio site and i created an xml slideshow with the help of postings from this forum. Everything is working fine but when i uploaded my swf in a temporary webspace and tested i noticed a strange thing which i cannot figure out the cause. The setinterval delay time is counting the time of preloading too. so the big size images are sometimes skipped and next image is getting loaded. here is my code.

delay = 10000;  
this.fadeSpeed = 5;  
this.fadeOutSpeed = 10;  
var fadOutInt:Number;

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(“main.xml?task=refresh”);  
/////////////////////////////////////  
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() {  
prevact();  
};  
next\_btn.onRelease = function() {  
nextact();  
};  
/////////////////////////////////////  
p = 0;  
this.onEnterFrame = function() {  
filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
preloader.\_visible = true;  
numload\_txt.\_visible = true;  
if (loaded != filesize) {  
numload\_txt.text = Math.round(loaded/filesize \* 100) + " %";  
preloader.preload\_bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;  
numload\_txt.\_visible = false;  
if (picture.\_alpha\<100) {  
picture.\_alpha += fadeSpeed;  
}

}  
}  
function setstage(){  
picture.\_alpha = 0;  
desc\_txt.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
slideshow();  
}  
function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
setstage();  
}  
}  
}  
function prevact() {  
clearInterval(myInterval);  
if (p == 0){  
p = total - 2;  
} else {  
p = p - 2;  
}  
fadeOut();  
}  
function nextact() {  
clearInterval(myInterval);  
fadeOut();  
}  
function firstImage() {  
if (loaded == filesize) {  
setstage();  
if (total \<= 1){  
clearInterval(myInterval);  
}  
}  
}  
function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
}  
function slideshow() {  
myInterval = setInterval(pause\_slideshow, delay);  
function pause\_slideshow() {  
clearInterval(myInterval);  
if (p == (total-1)) {  
p = 0;  
firstImage();  
} else {  
fadeOut();  
}  
}  
}  
function fadeOut() {  
fadeOutInt = setInterval(fadeOutImg, fadeOutSpeed);  
}  
function fadeOutImg(){  
if(picture.\_alpha \< 1){  
clearInterval(fadeOutInt);  
loadNextImg();  
}  
else{  
picture.\_alpha -= fadeOutSpeed;  
desc\_txt.\_alpha -= fadeOutSpeed;  
updateAfterEvent(); // refresh according to setInt delay, not framerate  
}  
}  
function loadNextImg() {  
if (p == (total-1)) {  
p = 0;  
firstImage();  
} else {  
nextImage();  
}  
}

Pls have a look and help me to figure out why this is happening.  
Thank you
