PDA

View Full Version : setInterval issues



killerguy3
03-01-2011, 05:35 PM
I need to find a way to speed up and slow down the speed of a slideshow with the setInterval function, I have tried a lot of ways but nothing works this is getting frustrating any help will be appreciated this is my javascript code:


<script type="text/javascript">
var num = 1, slideshow;
var speed = 2000;
picarray = new Array();
function slide() {
document.getElementById("pica").src = picarray[num];
if (num == 10)
num = 1;
else
num++;
}

function starts(speedSet) {
document.getElementById("start").value = "continue";

for (i = 1; i <= 10; i++) {
switch(i){
case 5:
picarray[i] = "Array/" + i + ".png";
break;
default:
picarray[i] = "Array/" + i + ".jpg";
break;
}
}
slideshow = setInterval('slide()', speedSet);
}
function stops() {
clearInterval(slideshow);
}
function speedup() {

speed += 1000;
stops();
starts(speed);

}
function slowup() {

speed -= 1000;
stops();
starts(speed);

}
var int = 0;
function begin() {
if (int == 0) {
starts(speed);
document.getElementById("play").src = "images/Pause.png";
int++;
}
else {
stops();
document.getElementById("play").src = "images/Play.png";
int = 0;
}
}
</ script >

thx in advance