Skip to main content
Participant
February 19, 2007
Answered

best way to do timeout prompts?

  • February 19, 2007
  • 6 replies
  • 377 views
I'm using MX 2004, and I need voiceover timeout prompts. What's the best way to accomplish the timing? I've used onEnterFrame to count down some timers, but, but I've had mixed results - they don't have to be too accurate, just working with some predictabillity. I'm also concerned that using onEnterFrame may slow things down too much.

I tried to use setInterval directly, and have the interval clear itself, but it didn't. I also tried Senocular's setTimeout function that uses setInterval, but it only runs once, same kind of thing I tried in simpler form. I tried different things and now I'm all confuzzled - sometimes they work and sometimes not. I should probably start from scratch (again), but deadlines are looming and I can't think straight anymore - I'm just kind of thrasing around - I also tried a "do nothing" loop, but then I get a "slow script" warning.

I think part of the problem is that I have some voiceovers as prompts and they aren't finished by the time the interval is cleared. I preloaded them into a swf and am loading the movie that way.

Advice is greatly appreciated, TIA!
This topic has been closed for replies.
Correct answer kglad
setInterval() always works and is fairly accurate unless you need close to 10 millisecond accuracy (in which case you can correct setInterval to maintain accurate timing).

any problem with clearing your intervals is a coding and coder problem.

6 replies

kglad
Community Expert
Community Expert
February 20, 2007
you're welcome.
Participant
February 20, 2007
Roger that. I had a hard time debugging because I wasn't sure if there was some behavior I was unaware of. I think it's working reasonably well now.

Thanks again.
kglad
Community Expert
Community Expert
February 20, 2007
you need an _rootI2vo1.start() in frogAudio or (and not both) _root.audioHolder_mc.I2vo1.start() in your main swf to start your sound. if that start() is executing once, your sound will play once.
Participant
February 20, 2007
I came across your suggestion to clearInterval before setInterval (in several threads), so I started doing it. I'm also using stopAllSounds() when a button is pressed.

This is how the sounds are loaded: in frogAudio.swf, a 1 frame swf, I have the sound files in the library, then do this:

_root.l2vo1=new Sound(this);
_root.l2vo1.attachSound("L2_VO1.wav");

Then in the first frame of the movie, I have an empty audioHolder_mc, and load the file with:

_root.audioHolder_mc.loadMovie("frogAudio.swf");

T
kglad
Community Expert
Community Expert
February 19, 2007
1. always use clearInterval() PRIOR to each setInterval() and again when a termination condition is met.

2. how is your sound created? with actionscript or attached to a timeline?
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 19, 2007
setInterval() always works and is fairly accurate unless you need close to 10 millisecond accuracy (in which case you can correct setInterval to maintain accurate timing).

any problem with clearing your intervals is a coding and coder problem.
Participant
February 19, 2007
Thanks - I agree that it's the old "nut loose behind the keyboard." if I know it's me, I can work with it.
I just forgot the "Don't Panic" maxim.

One thing though, is there any condition other than a code problem where a short audio clip could play twice during an interval? At the time it was a one-frame application, mostly ActionScript, and I cleared the interval after starting the sound right in the function itself.