I've created an audio player with actionscript 3 which plays one of 55 different sounds, depending on a variable set from which button a user clicks on. It works fine for the first 1 or 2 plays, but after that the sound begins to double-up, or even triple-up. I'm using the code below.

First I declare a few variables:

var sound:Sound;
var controller:SoundChannel;
var pausePos:Number = 0;
var audioReset:Boolean = false;
var playerObject:Object = new Object();

The sound functions are placed within another function so that it can be called again once a new button is selected:

function audiofunc() {

//if the user is selecting a second audio file, it runs this "audioReset function to try to clear the EventListeners
if (audioReset == true) {
audio.play_btn.removeEventListener(MouseEvent.CLIC K, playSound);
audio.pause_btn.removeEventListener(MouseEvent.CLI CK, stopSound);
playerObject.sound.removeEventListener(Event.COMPL ETE, soundLoaded);
playerObject.sound.removeEventListener(ProgressEve nt.PROGRESS, preloadAudio);
delete playerObject.sound;
flash.media.SoundMixer.stopAll(); //stop all sounds that might be playing
controller = null;
}

audio.audio_loader.visible = true; //show the loading screen over the button
audio.pause_btn.visible = false; //hide pause button
audio.play_btn.visible = true; //show play button

var audioreq:URLRequest = new URLRequest (partnerOn+"_audio.mp3");
playerObject.sound = new Sound();

playerObject.sound.addEventListener(Event.COMPLETE , soundLoaded, false, 0, true);
playerObject.sound.addEventListener(ProgressEvent. PROGRESS, preloadAudio, false, 0, true);
playerObject.sound.load(audioreq);

function preloadAudio(event:ProgressEvent):void {
var percent2:Number = Math.round (event.bytesLoaded / event.bytesTotal * 100);
audio.audio_loader.audio_preload_txt.text = String(percent2) + " %";
}

function soundLoaded(event:Event):void {
controller = playerObject.sound.play();
controller.stop();
audio.audio_loader.visible = false;
audio.play_btn.addEventListener(MouseEvent.CLICK, playSound, false, 0, true);
audio.pause_btn.addEventListener(MouseEvent.CLICK, stopSound, false, 0, true);
}

function playSound(event:MouseEvent):void {
controller = playerObject.sound.play(pausePos);
audio.play_btn.visible = false;
audio.pause_btn.visible = true; //show pause button
}

function stopSound(event:MouseEvent):void {
pausePos = controller.position;
controller.stop();
flash.media.SoundMixer.stopAll();
trace(pausePos);
audio.play_btn.visible = true; //show play button
audio.pause_btn.visible = false;
}
}

audiofunc();

I'm assuming that somehow an EventListener isn't getting removed, so it's causing a few versions of the audio file to play at once.

If anyone has any suggestions, I would be most grateful.