Groups | Blog | Home
all groups > flash actionscript > february 2007 >

flash actionscript : best way to do timeout prompts?


TomFantasia
2/19/2007 8:32:18 PM
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!
kglad
2/19/2007 9:43:57 PM
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.
TomFantasia
2/19/2007 11:01:50 PM
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.
kglad
2/19/2007 11:57:29 PM
1. always use clearInterval() PRIOR to each setInterval() and again when a termination condition is met.

TomFantasia
2/20/2007 12:14:28 AM
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
2/20/2007 12:20:42 AM
TomFantasia
2/20/2007 12:49:20 AM
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.

kglad
2/20/2007 12:58:19 AM
AddThis Social Bookmark Button