stop other sounds?

  • whiteybags
  • Born
  • Born
  • whiteybags
  • Posts: 3

Post 3+ Months Ago

I have eight buttons. Each button plays a different sound.

If the sound is playing from button1 & I press button2 the sound from button2 plays over the first sound.

How do I get it so that when I press button2 the sounds from all the other buttons stops & ONLY the sound from button2 plays?

Please help :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

what you want will take some time for you to learn a little about the
sound object in flash, and how it works with interativity. The best place
on the net to learn about sound in flash is here:

http://www.kennybellew.com/tutorial/
  • whiteybags
  • Born
  • Born
  • whiteybags
  • Posts: 3

Post 3+ Months Ago

I had already gone through that...it tells you how to attach sounds, loop sounds etc...but not stop any sound that is already playing to play the new sound that you have just clicked on.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

I hate to ask the obvious, but have you tried...

Code: [ Select ]
stopAllSounds()


?

It's been around since Flash 3.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

EDIT: DM's method looks pretty good :D never thought of that.


How is your soundSystem setup ?

Being you have sounds playing on top of eachother i'm guessing you have each sound attached to it's own soundObject, somthing like this maybe ?,
Code: [ Select ]
testSound = new Sound();
testSound.attachSound("sound1.wav");
testSound2 = new Sound();
testSound2.attachSound("sound2.wav");
but.onPress = function(){
    testSound.start(0,0);
}
but2.onPress = function(){
    testSound2.start(0,0);
}
  1. testSound = new Sound();
  2. testSound.attachSound("sound1.wav");
  3. testSound2 = new Sound();
  4. testSound2.attachSound("sound2.wav");
  5. but.onPress = function(){
  6.     testSound.start(0,0);
  7. }
  8. but2.onPress = function(){
  9.     testSound2.start(0,0);
  10. }


If that's the case try creating an empty soundObject named nowPlaying to keep track of what soundObject is currently running.
In the actions calling each sound to start() assign the value of nowPlaying to the soundObject that the button starts.
Here's a brief example,
Code: [ Select ]
testSound = new Sound();
testSound.attachSound("sound1.wav");
testSound2 = new Sound();
testSound2.attachSound("sound2.wav");
nowPlaying = new Sound();
soundOneButton.onPress = function(){
    nowPlaying.stop();
    nowPlaying = testSound;
    testSound.start(0,10);
}
soundTwoButton.onPress = function(){
    nowPlaying.stop();
    nowPlaying = testSound2;
    testSound2.start(0,10);
}
  1. testSound = new Sound();
  2. testSound.attachSound("sound1.wav");
  3. testSound2 = new Sound();
  4. testSound2.attachSound("sound2.wav");
  5. nowPlaying = new Sound();
  6. soundOneButton.onPress = function(){
  7.     nowPlaying.stop();
  8.     nowPlaying = testSound;
  9.     testSound.start(0,10);
  10. }
  11. soundTwoButton.onPress = function(){
  12.     nowPlaying.stop();
  13.     nowPlaying = testSound2;
  14.     testSound2.start(0,10);
  15. }
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

whiteybags wrote:
I had already gone through that...it tells you how to attach sounds, loop sounds etc...but not stop any sound that is already playing to play the new sound that you have just clicked on.

exactly - and if you had done all of it and thought about it in terms of
your current knowledge of flash you probably could have figured it out
on your own.

I'm not one for spoonfeeding info, sorry. You'll learn so much more doing
things on your own, instead of asking for answers.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.