[quoted text, click to view] "alreadytaken" <webforumsuser@macromedia.com> wrote in message
news:c8imrp$1ri$1@forums.macromedia.com...
> I used your script exactly as you have it... and it works... kinda. If you
> click the up and down buttons too rapidly, say a 3 seconds apart or
less... it
> fails! The sound starts increasing beyond 100%. Also, if I want to change
the
> step from -3 to -10, the music never completely fades out, and still
encounters
> the problem that it looses itself. I believe this is because this is an
> interpreted language and if you interupt the script in a previous loop to
begin
> running in another loop, if fails.
>
> Can you modify and add some traps for this? Thanks. BTW, this is the only
code
> that worked out of several examples from other sites that I tried. Thanks
for
> your help.
Yes, you are right. I didn't test it enough. We can fix it with just one
line on each of the two buttons to clear the interval (whether it needs it
or not) before setting the interval again. It makes sure that two timer
intervals are not running at the same time.
tralfaz
// code for fade up button
on (release)
{
clearInterval(_root.fade); // add this line
step = 3; // increase volume
_root.fade = setInterval(fadeSound, 100);
}
// code for fade down button
on (release)
{
clearInterval(_root.fade); // add this line
step = -3; // increase volume
_root.fade = setInterval(fadeSound, 100);
}