Hi!
of cause, you already know, i'm gonna say im new to javascript and blahblahblah.... anyway, its a simple changing images animation starting by clicking on button. However, i stuck on stopping animation by clicking "stop" button.... here is my code, please if somebody can take time to look at it, i would really appreciate it!
<script language="JavaScript">
// Preloaded images
if (document.images)
{
demo1 = new Image();
demo1.src = "images/breakdance1.gif"
demo2 = new Image();
demo2.src = "images/breakdance2.gif";
demo3 = new Image();
demo3.src = "images/breakdance3.gif";
demo4 = new Image();
demo4.src = "images/breakdance4.gif"
demo5 = new Image();
demo5.src = "images/breakdance5.gif"
demo6 = new Image();
demo6.src = "images/breakdance6.gif"
demo7 = new Image();
demo7.src = "images/breakdance7.gif"
demo8 = new Image();
demo8.src = "images/breakdance8.gif"
}
// Reusable timer
function timeimgs(numb)
{
thetimer = setTimeout("imgturn('" +numb+ "')", 1000);
}
// Reusable image turner
function imgturn(numb)
{
if (document.images)
{
// This will loop the image
if (numb == "8")
{
document["demo"].src = eval("demo8.src");
timeimgs('1');
}
else
{
document["demo"].src = eval("demo" + numb + ".src");
timeimgs(numb = ++numb);
}
}
}
</script>
<body>
<img src="images/breakdance1.gif" name="demo"/> <form action=""><p> <input type="button" value="Watch this lesson" onclick="timeimgs('2');"/><input type="button" value="stop" onclick="clearInterval(timeimgs);"/> </p></form>
</body>