Click to See Complete Forum and Search --> : need a function to run continuously...


krautinator
11-14-2003, 09:53 AM
Does anyone know how to work with setInterval()?
I don't really know how to use that method...
here's what I want to do:
I have this code:

<script>



if(document.all && newdirection < 100){

function changedirection(newdirection){

newdirection += 10
document.all.fading.style.filter="alpha(finishOpacity="+newdirection+",style=3)"

setTimeout ("changedirection(" +newdirection+ ")", 10)
}


}


function changedirectionback(newdirection) {

if(document.all && newdirection > -100){



newdirection -= 10
document.all.fading.style.filter="alpha(finishOpacity="+newdirection+",style=1)"

setTimeout ("changedirectionback(" +newdirection+ ")", 10)
}


}

</script>

I want the two highlighted functions to run continuously while the user is there, the functions just change the finishOpacity of an image, to make it look like a sort of "light energy" is running across it

here's the whole thing put together (I temporarily called the function in the body onLoad event, so you might have to look real close to notice the change...):

http://www.geocities.com/krautinator2001//fadetest.html

the other function just moves the finishOpacity back
I want to call them both about every 1 or 2 seconds

Any help would be appreciated :cool:

pixelmech
11-14-2003, 10:19 AM
Hey Kraut,

I wrote an article for Evolt.org on setInterval(). It should give you the info that you need:

http://www.evolt.org/article/Using_setInterval_to_Make_a_JavaScript_Listener/17/36035/index.html?cfid=3686399&cftoken=90477234

HTH

Tom