Array

Stopping Sounds, Resuming Sounds

Must Read

Admin
Admin
Just post!

Stopping Sounds

To stop a sound from playing, simply call the stop function on its channel:

channel.stop();

To stop streaming audio, calling the stop function works once, but the sound starts playing again from the beginning. This is because the stream is still downloading. You also need to stop the downloading process:

channel.stop();
sound.close();

If you have several sounds playing at the same time, you can stop the sounds of all the channels one at a time.

The best approach is to use the static SoundMixer class, which controls embedded and dynamic sounds and the mixed output from multiple sound channels. You can use this class to stop as well as control the volume of all the sounds currently playing:

SoundMixer.stopAll();

Resuming Sounds

There is no direct way to pause a sound and then resume playing, but you can easily create the same effect by storing the position of the channel where you stop, and start from that same position when playing again:

var lastPosition:int = channel.position;
channel.stop();
// to resume from the same position
sound.play(lastPosition);

- Advertisement -

Latest News

Unpacking Fixed Rate HELOCs: The Good, the Bad, and Everything In Between

Today, we're diving deep into the world of Fixed Rate Home Equity Lines of Credit (HELOCs). If you're a...
- Advertisement -

More Articles Like This

- Advertisement -