...

View Full Version : activetimeout help pls



g00fy
02-23-2003, 08:02 AM
sorry subject should say setTimeout help pls :o

hi to all, :)

can u pls look at code below and tell me why my previous method is not happening properly.

i think code explains itself, else let me know.

the timeout is not resetting on previous function


thanx all :thumbsup:



<html>
<head>
<title>Test Slideshow</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
var activeTimeout=false;
var halt = false;
var backward = false;

var delay = 3000; // image delay (millisec)
var transition = 0; // transition time (sec)

var imgObjects = new Array("about.gif", "album.gif", "about_over.gif") ;
var imageArray = new Array();

var a = 0;
var b;

for (i = 0; i < imgObjects.length; i++){
imageArray[i] = new Image();
imageArray[i].src = imgObjects[i];
}

function swapImage(){
b = document.images.SlideShow.src;
if(!halt){
if (document.all){
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=transition)";
document.images.SlideShow.filters.blendTrans.Apply() ;
}
if(!backward){
document.images.SlideShow.src = imageArray[a].src;
if (document.all){
document.images.SlideShow.filters.blendTrans.Play();
}
a = a + 1;
}else{
document.images.SlideShow.src = b;
if (document.all){
document.images.SlideShow.filters.blendTrans.Play();
}
backward = false;
}
if (a > (imgObjects.length-1))
a = 0;
activeTimeout = setTimeout("swapImage();activeTimeout=false", delay);
}
}

function next(){
halt = false;
if (activeTimeout)
clearTimeout(activeTimeout);
swapImage();

}

function previous(){
halt = false;
if (activeTimeout)
clearTimeout(activeTimeout);
backward = true;
swapImage();

}

function stopNow(){
halt = true;
document.images.SlideShow.src = document.images.SlideShow.src;
activeTimeout = false;
}

</script>



</head>

<body onload="swapImage()">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="VU" height=150 width=150> <img src="about.gif" name='SlideShow' width=150 height=20></td>
</tr>
</table>
<input type="submit" name="prev" value="<< Previous" onClick="previous()">
<input type="submit" name="stop" value="Stop !" onClick="stopNow()">
<input type="submit" name="next" value="Next >>" onClick="next()">
</body>
</html>


gave you whole html so u can cut and paste if need be :)


kind regards,

g00fy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum