If youâre only creating one instance of each sound effect (like in this tutorial), then a new instance of the sound will stop one thatâs already playing; If you donât want the second sound to cancel out the first, you;ll want to create a new instance of the sound effect every time you play it.
What I usually do is import all my sounds into one class, then have a static function that I can call to play them:
package
{
public class Assets
{
import net.flashpunk.Sfx;
//Mp3 sounds:
[Embed(source = '../assets/snd_bonus.mp3')]
public static const snd_bonus:Class;
public function Assets()
{
}
public static function playMp3(whatmp3:Class, _vol:Number = 1, _pan:Number = 0):void {
var snd:Sfx = new Sfx(whatmp3);
snd.play(_vol * ((Math.exp(Global.volume / 10) - 1) / (Math.E-1)), _pan);
}
}
}
This will create a new instance of every sound that you play.