flash cs3 playlist

How to build a play list on flash cs3 using the list as toggle buttons?
Hi, I need  to crate a flash file that will served as a soundtrack.
I have a list of 9 titled songs converted each one into buttons. All I want is to make each button play the sample audio belonging to the song title. I manage to make it play but I have more than one so my problem is that I need for each button to turn off the previous first and then play the new audio in case user switches to next song before the first one ends.

This is my code sample for just 2 buttons so far:
mySound = new Sound();
mySound.attachSound("parriba");

song1_btn.onRelease = function() {
      mySound.start();

}

mySound = new Sound();
mySound.attachSound("lloroporti");

song2_btn.onRelease = function() {
      mySound.start();
}
Picture-18.png
Mlo-DesignsAsked:
Who is Participating?
 
blue-genieConnect With a Mentor Commented:
this should work

//as2
function playSound(which:String) {
var mySound:Sound = new Sound();
stopAllSounds();
mySound.attachSound(which);
mySound.start();
}
 
btn1.onRelease =function() {
playSound("a");
}
btn2.onRelease = function() {
playSound("b");
}

Open in new window

0
 
Mlo-DesignsAuthor Commented:
OMG- Worked like a charm. Thank You Very Much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.