Page 1 of 1

ScriptTimer Question

PostPosted: Mon Aug 19, 2019 2:21 pm
by Sk8cynic
Hi,

I created a script timer that incrementally lowers the volume (fades out) of the music on a page when a button (FadeBtn) is pressed.
The script I have is:

VolumeDown()
ScriptTimer("FadeBtn","500")
VolumeDown()
ScriptTimer("FadeBtn","500")
VolumeDown()
ScriptTimer("FadeBtn","500")
VolumeDown()
ScriptTimer("FadeBtn","500")

The script runs fine but when the volume is returned to its initial setting (100), the timer runs automatically and lowers the volume as long as it is on the same page.

According the Help File, the only way to kill a scriptimer is to leave the page and then return or go to another page. That is true and the timer works if another page is chosen. I want to be able to kill the script each time it is run on the same page. I tried using things like PageTimer with a zero value to reset the page but that doesn't seem to work.

Anybody run into this and is there a way to kill/stop the scripttimer if it's still on the same page?

Thanks for any help!

Re: ScriptTimer Question

PostPosted: Mon Aug 19, 2019 3:06 pm
by dgilmour
Code: Select all
vol = CBK_Volume
If (vol) Then
  VolumeDown()
  ScriptTimer("FadeBtn","500")
End

A text object with the "CBK_Volume" label must exist on the page.

Re: ScriptTimer Question

PostPosted: Mon Aug 19, 2019 4:08 pm
by Sk8cynic
dgilmour,

Thank you for your quick reply! It worked perfectly! I forgot to ask...how do I stop the sound at the end of the timing period? (my bad)

Thank you again for your help!

Re: ScriptTimer Question

PostPosted: Mon Aug 19, 2019 7:33 pm
by dgilmour
If you mean stopping playback after fade out then this modified code should do the job:
Code: Select all
vol = CBK_Volume
If (vol) Then
  VolumeDown()
  ScriptTimer("FadeBtn","500")
Else
  StopSound()
End

Re: ScriptTimer Question

PostPosted: Mon Aug 19, 2019 9:03 pm
by Sk8cynic
dgilmour,

LOVE IT! Perfect!

Again, thank you so much!!