Skip to main content
Known Participant
September 23, 2009
Answered

loading a sound file from the library to play it in one frame

  • September 23, 2009
  • 1 reply
  • 587 views

I am new to actionscript. I have a flash file with several frames. In each frame I need to play a sound file.

I've added all the sounds to the library and done all the necessary steps to export for actionscript.

Here's my code to play the sound in one frame.

var sound1:Sound = new Cal10101();

sound1.play();

This works great to play the sound. I am using buttons to move to the next frame. When I click the button to move to the next frame, I need the sound from frame 1 to stop and a new sound which would be Cal10102 to start playing.

How do I stop the sound from frame 1 from playing when I go to the next frame?

Thanks,

Steve

This topic has been closed for replies.
Correct answer kglad

what you should do is use:


var sound1:Sound = new Cal10101();

var sound1SC:SoundChannel = sound1.play();


and before you goto the next frame execute:

sound1SC.stop();

// but you'll probably find it easier to use:

SoundMixer.stopAll();

before going to the next frame

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 23, 2009

what you should do is use:


var sound1:Sound = new Cal10101();

var sound1SC:SoundChannel = sound1.play();


and before you goto the next frame execute:

sound1SC.stop();

// but you'll probably find it easier to use:

SoundMixer.stopAll();

before going to the next frame

color_mAuthor
Known Participant
September 23, 2009

That works! thanks for your help!

Much appreciated.

Steve

kglad
Community Expert
Community Expert
September 23, 2009

you're welcome.