Groups | Blog | Home
all groups > flash (macromedia) > december 2003 >

flash (macromedia) : Making sound Pause


0078a
12/7/2003 10:17:37 PM
Does anyone know how to get sound to pause???
I can get it to stop but I need to pause the sound and then resume at the point where it left off.
Can anyone point me to a website or if someone already has a script that can do that, that would be helpful to be able to see the code.

Thanks


urami_
12/8/2003 7:36:25 AM

[quoted text, click to view]

Very easy if you use STREAM sound . Because stream is frame based , once the timeline
on which you run the stream is stopped, the sound stop as well.
So all you have to do is place sound in movie clip , stream it than simply
MC.stop(); to pause it and MC.play(); to resume.

If stream is not desirable type , than with more action script we can as well
control event sound using sound object .

Give the sound linkage name "soundLoop"

(open library CTRL L , right click your sound , go to linkage ,
check the box Export For ActionScript and key in id name "soundLoop")

and on timeline :

mySound = new Sound();
mySound.attachSound("loopsound");
mySound.onSoundComplete = function() {
mySound.start();
};


Button to Start the sound :

on (release) {
_root.mySound.start(_root.pos);
_root.pos = 0;
}

Button to Pause the sound :

on (release) {
_root.mySound.stop();
_root.pos = mySound.position/1000;
}

This is most simplified version so it has it's flaws.
If you click start button twice it will run audio a bit messy
so best if you place buttons in movie clip with two frames .
Each on different frame , once you click button , jump to next frame
so you only see the PAUSE , once click pause jump previous frame to
only see START . It will prevent users from messing it up .


as simple as that .......



Regards

urami_*



<lsym>

There's no place like 127.0.0.1

AddThis Social Bookmark Button