ScriptTimer Question

Multimedia Builder

ScriptTimer Question

Postby Sk8cynic » Mon Aug 19, 2019 2:21 pm

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!
Sk8cynic
 
Posts: 28
Joined: Thu Oct 04, 2012 12:51 pm

Re: ScriptTimer Question

Postby dgilmour » Mon Aug 19, 2019 3:06 pm

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.
dgilmour
 
Posts: 523
Joined: Fri Oct 22, 2010 11:29 am
Location: Moskva, Rusko

Re: ScriptTimer Question

Postby Sk8cynic » Mon Aug 19, 2019 4:08 pm

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!
Sk8cynic
 
Posts: 28
Joined: Thu Oct 04, 2012 12:51 pm

Re: ScriptTimer Question

Postby dgilmour » Mon Aug 19, 2019 7:33 pm

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
dgilmour
 
Posts: 523
Joined: Fri Oct 22, 2010 11:29 am
Location: Moskva, Rusko

Re: ScriptTimer Question

Postby Sk8cynic » Mon Aug 19, 2019 9:03 pm

dgilmour,

LOVE IT! Perfect!

Again, thank you so much!!
Sk8cynic
 
Posts: 28
Joined: Thu Oct 04, 2012 12:51 pm


Return to MMB

Who is online

Users browsing this forum: No registered users and 3 guests