Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-23-2003, 07:02 AM   PM User | #1
g00fy
New Coder

 
Join Date: Jan 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
g00fy is an unknown quantity at this point
setTimeout help pls

sorry subject should say setTimeout help pls

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

Code:
<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

Last edited by g00fy; 02-23-2003 at 07:24 AM..
g00fy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:16 PM.


Advertisement
Log in to turn off these ads.