EDIT: DM's method looks pretty good

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 ?,
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);
}
- 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);
- }
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,
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);
}
- 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);
- }
Strong with this one, the sudo is.