Preserved Topic: Any way to cancel queued setTimout events? (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 05-28-2000 09:57
Well, the saga continues on my overly embellished Doc script at http://www.coffman.umn.edu/insider/ <P>By adding a 'done' boolean variable I was able to keep the events seperate, but they still can go loopy if people mouse over too many too quickly, which, sadly, seems to be a common occurrence. All I need now is a way to cancel setTimoouts after the fact. Is there a command to do this or what? |
Maniac (V) Lord Mad Scientist Sovereign of all the lands Ozone and just beyond that little green line over there... From: Stockholm, Sweden |
posted 05-28-2000 11:35
Well, that would have to be the clearTimout() statement, yep! You need to do two things, first you need to name your timeouts, like...<P>mytimeout = setTimeout('function()', 1000);<P>And then to end it, you need this...<P>clearTimeout('mytimeout');<P>I'm not sure if the single quotes need to be there or not, I don't use this feature too often, I usually use flags in my functions to control these things, Timeouts can be flaky sometimes. (Smoke/drink page is done this way.)<P> |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 05-28-2000 18:27
yeah, the quotes need to be there... it works like this:<P>identifier = setTimeout("statements to execute", milleseconds_to_wait);<P>clearTimeout(identifier);<P>You can also use the setInterval function, which works the same way, except that it continues to execute the code more than once, at the same interval which you specified. I don't see many people using this... I use it almost all the time. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 05-28-2000 20:42
Oh, single quotes or double quotes, doesn't matter - both do the same thing in JavaScript. |
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 05-31-2000 18:11
How would u use a flag to set up this situation? Is there another way to animate multiple images without using setTimeouts at all? Well, I'm off to check out the smoking/drinking JS. |
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 05-31-2000 19:25
Well, spy this javascript snippet:<P>function resetImages() |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 05-31-2000 19:27
What do you mean by a "flag"? |
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 05-31-2000 19:39
I assume Doc just means a boolean variable. |
Maniac (V) Lord Mad Scientist Sovereign of all the lands Ozone and just beyond that little green line over there... From: Stockholm, Sweden |
posted 06-01-2000 00:32
Yah, real low tech stuff here, like...<P>var do_me_now = 1;<P>...so you can check to see...<P>if (do_me_now) {...} |
Maniac (V) Inmate From: under the bed |
posted 06-01-2000 01:19
Hey Doc, I think you've got the wrong thread in mind...the do_me_now function belongs in the "applets" thread <img border=0 align=absmiddle src="http://www.ozones.com/forum/smile.gif"><P> |
Maniac (V) Lord Mad Scientist Sovereign of all the lands Ozone and just beyond that little green line over there... From: Stockholm, Sweden |
posted 06-01-2000 13:20 |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 06-01-2000 21:09
lol, I'd like to see those functions!<P>I have a friend who comes up with the wackiest variable names; occasionally he's been upset at the QBasic variable name character limit of something like 32 or 64 characters. |