"Michael Winter" <M.Winter@[no-spam]blueyonder.co.uk> wrote in message
news:5ZRsb.3277$nT.27507763@news-text.cableinet.net...[color=blue]
> "TheKeith" wrote on 13/11/2003:
>
> <snip>
>[color=green]
> > thesubject.onmouseout = clearInterval(cycle);[/color]
> setInterval(backcycler,300);
>
> When specifying handlers like this, you must use the function name
> only. If you include the parentheses, the function is called
> immediately. This means that you can't specify parameters. Also, the
> setInterval() call above will always be called: the preceeding
> semi-colon marks the end of the assignment. You could put all of your
> script on the same line and it wouldn't change how it was executed.
> The assignment and setInterval() call are two separate statements. To
> fix this, define a new nested function:
>
> function myMouseOut()
> {
> window.clearInterval( cycle );
> backcycle = setInterval( backcycler, 300 );
> // You need the timer ID to cancel the interval later!
> }
>
> and add these to your main function:
>
> var backcycle = null; // With the declarations
> ...
> thesubject.onmouseout = myMouseOut;
>
> <snip>
>[color=green]
> > function backcycler() {
> > if (i > 0) {
> > i = i - 1;
> > thesubject.src = theimgs[i];
> > }
> > else {
> > clearInterval(backcycler);[/color]
>
> This is invalid. You can't specify a function for an interval ID
> (hence the new variable I introduced above).
>
> <snip>
>[color=green]
> > Now, I realize the problem is with the "thesubject.onmouseout =
> > clearInterval(cycle); setInterval(backcycler,300);" statement, but I[/color]
> can't[color=green]
> > figure out why it isn't working. I thought you could use event[/color]
> handlers as[color=green]
> > object properties? Help would be appreciated--thanks.[/color]
>
> Hopefully, that will help somewhat.
>
> Mike
>
> --
> Michael Winter
>
Join Bytes! (remove [no-spam] to reply)[/color]
I'm an idiot. It works great! Thanks a lot, Mike.