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

flash actionscript : sound pause and resume


calhoontuna
3/2/2007 9:04:00 PM
Built an audio pause/resume button. The idea is that you hit the button once
and it will pause sound. Hit it again and the sound will resume right where
you left off. Problem is that sometimes the button works while at other times
you'll hit it and start up another instance of the same audio track so that
you'll be hearing the sound doubled but half a second off. It's variable
sometimes it works, sometimes not. Hoping someone can tell me what's going on
here.

The specifics: I have 37 slides, each of which is accompanied by a sound
bite. The sound was imported into Flash than linked and exported for
ActionScript. On each slide, the audio is called by:
stop();
mySound=new Sound(this);
mySound.attachSound("25");
mySound.onSoundcomplete=function()
{
nextFrame();
};
mySound.start(0,1);

The pause button has the following ActionScript attached to it:
on(release){
if(!paused){
soundPosition=mySound.postion/1000
mySound.stop();
paused=true;
}else{
mysound.start(soundPosition,true);
paused=false;
}
}
kglad
3/3/2007 1:25:06 AM
that 2nd parameter in the sound class start() method should be the number of
loops, not a boolean. and your on(release) coding can be tighter:



on(release) {
if (!paused) {
mySound.stop();
} else {
mysound.start(mySound.postion/1000, 1);
}
paused = !paused;
};
AddThis Social Bookmark Button