Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: How do I re-initialize this javascript animation? - September 10, 1998 at 06:12:44

You are here: irt.org | BBS | How do I re-initialize this javascript animation? [This BBS is closed]

Posted by Yvan Gagnon on September 10, 1998 at 06:12:44:

Hi. I have this image changeout script that triggers a 10-frame javascript animation on another
layer, and I can't seem to figure out a way to re-initialize it onMouseout so that multiple
instances of it can't run simultaneously. Each time I trigger the animation onMouseover, it gets
faster and faster until it just becomes this strobing blur. Here's the script:

<SCRIPT LANGUAGE="JavaScript">

var timer
var counter = 1

function animatefire () {
timer = setTimeout ("animatefire ()",150);
counter++;

if (counter < 10) {
document.layers['layer1'].document.images['fire'].src = imgs[counter].src

}
else {
clearTimeout (timer);
counter = 1;
document.layers['layer1'].document.images['fire'].src = imgs[counter].src;
animatefire ()

}
}

And then after the body tag I have ...

<SCRIPT LANGUAGE="JavaScript">


if (document.images){

var imgs = new Array ()
for (var i = 1; i < 10; i++) {
imgs[i] = new Image (70, 36)
imgs[i].src = 'images/fireanim/' + i + ".gif"
}
}


How would I write a function that reinitializes this method somehow, so that multiple instances
of it can't be called? Or would anyone happen to know of a BETTER javascript animation
script I could use that doesn't have bug in it?

Thanks,
-- yvan@intersolutions.com
Follow-ups:

You are here: irt.org | BBS | How do I re-initialize this javascript animation? [This BBS is closed]

©2018 Martin Webb