A simple button press with sounds and audioloop question

Hi, I’m trying to put together a simple flash file for a project I’m wokring on and can’t seem to work out the actionscript (2.0) to do what i want! Wondered if someone would be able to help me here?

It’s very simple what i want to do… I have 3 short sounds and one button.

On pressing the button i want the sound1 to play, then as soon as it’s finished start looping sound2 untill the button is released when sound3 would play.

I hope this makes sense.

Thanks for looking and hope someone can help

(I’m doing this in flash CS5 currently but have set my project up to be actionscript 2.0 can change this if there is an easier method)

Off the top of my head:



var snd1:Sound = new Sound(this);
var snd2:Sound = new Sound(this);
var snd3:Sound = new Sound(this);
snd1.attachSound("sound1");
snd2.attachSound("sound2");
snd3.attachSound("sound3");

btnButton.onPress = function() {
   snd1.start();
   snd1.onSoundComplete = function() {
      snd2.start(0, 999);
   }
}

btnButton.onRelease = function() {
   snd2.stop();
   snd3.start();
}

Where I’ve attached the sound with sound1, sound2 and sound3, these are the linkage names from the sound items in the library.

If the code above doesn’t work, it should be pretty close.

Hope it helps!

that’s great thanks so much!

You left a } in the code but I worked out where it needed to be.

Thanks again :slight_smile: