Buttons and wav sound loops as3 (almost made it)

Hi,everyone

I’ve been trying to make a sound-loop player for quite some time now (i’m new to as3) and i’m pretty close to do it but still i need a little help.

Ok, i’ve made six letters converted them into buttons and i want them to play a different wav sound loop each one whenever i click on them and to stop the sound when i click again.

This works fine for the first button but not for the rest of them because i dont know where to insert the similar code for the rest of the buttons.

Here’s the code that works perfect for the first button:

import flash.media.Sound;

var sound:Sound = new The_Rloop5();
var soundControl: SoundChannel = new SoundChannel();

          button_s.addEventListener(MouseEvent.CLICK, playSound);
          button_sstop.addEventListener(MouseEvent.CLICK, stopSound);

function playSound(event:MouseEvent):void
{
soundControl = sound.play(0, int.MAX_VALUE);
button_sstop.visible = true;
button_sstop.addEventListener(MouseEvent.CLICK, stopSound);
button_s.visible = false;
button_s.removeEventListener(MouseEvent.CLICK, playSound);

}

function stopSound(event:MouseEvent):void
{
soundControl.stop();
button_s.visible = true;
button_s.addEventListener(MouseEvent.CLICK, playSound);
button_sstop.visible = false;
button_sstop.removeEventListener(MouseEvent.CLICK, stopSound);

}

button_sstop.visible = false;

here’s the attempt to continue the code for the second button:

import flash.media.Sound;
var sound:Sound = new Afristic2();
var soundControl: SoundChannel = new SoundChannel();
button_s.addEventListener(MouseEvent.CLICK, playSound);
button_sstop.addEventListener(MouseEvent.CLICK, stopSound);

function playSound(event:MouseEvent):void
{
soundControl = sound.play(0, int.MAX_VALUE);
button_sstop.visible = true;
button_sstop.addEventListener(MouseEvent.CLICK, stopSound);
button_s.visible = false;
button_s.removeEventListener(MouseEvent.CLICK, playSound);

}
function stopSound(event:MouseEvent):void
{
soundControl.stop();
button_s.visible = true;
button_s.addEventListener(MouseEvent.CLICK, playSound);
button_sstop.visible = false;
button_sstop.removeEventListener(MouseEvent.CLICK, stopSound);

}

button_sstop.visible = false;

import flash.media.Sound;
var sound2:Sound = new DSkiller4();
var soundControl2: SoundChannel = new SoundChannel();
button_p.addEventListener(MouseEvent.CLICK, playSound2);
button_pstop.addEventListener(MouseEvent.CLICK, stopSound2);

function playSound2(event:MouseEvent):void
{
soundControl2 = sound.play(0, int.MAX_VALUE);
button_pstop.visible = true;
button_pstop.addEventListener(MouseEvent.CLICK, stopSound2);
button_p.visible = false;
button_p.removeEventListener(MouseEvent.CLICK, playSound2);

}
function stopSound2(event:MouseEvent):void
{
soundControl2.stop();
button_p.visible = true;
button_p.addEventListener(MouseEvent.CLICK, playSound2);
button_pstop.visible = false;
button_pstop.removeEventListener(MouseEvent.CLICK, stopSound2);

}

  button_pstop.visible = false;

Now the only thing that i managed to do is to play the same sound on both of the two buttons.
Thank you for any help…