Please help problem with sound
I'd really appreciate some help with teething problems on sound actionscript.
I have two background music's, which i'd like to fade out on change. I'm using the Sound Fade Object Extension from Remixology, recommended in the FAQ thread in this forum to fade out my sounds. Then I noticed that I need to make the next sound wait a little (until the fade has finished) before starting otherwise remixology doesnt like it. So I made a wait function. (Remixology)
Whilst my use of it is 'ok' when making slow transitions between frames, if I quickly click back and forward it causes all sorts of issues. The bg music supposed to start for frame 3 (then cancelled on move back) starts on frame 2. Sometimes the bg sound will start about 6 times on top of itself which makes a horrible droaning noise.
I've put the code i'm using below, and would really appreciate anyones time to have a look for me:
Frame 1
Code:
function wait(soundName:String) {
mysound = new Sound();
mysound.attachSound(soundName);
mysound.start(0, 999999);
clearInterval(waitInt);
}
// add extension located in this directory at compile time
#include "soundobjectfade.as"
attachMovie("sound", "sound", 6);
// initiate sound
bandofbrothers = new Sound();
bandofbrothers.attachSound("bandofbrothers");
bandofbrothers.start(0, 999999);
fromintro = true;
Frame2
Code:
if(!fromintro){
waitInt = setInterval(wait,5000, "bandofbrothers");
}
btnNextFrame.onPress = function () { // When button is pressed
gotoAndPlay("frame 3") // Go to frame 3 (below)
bandofbrothers.fadeToStop(0,4000); // fade volume from 100 to 0 over 4 seconds and stop sound.
}
Frame 3
Code:
enemyatgates = new Sound();
enemyatgates.attachSound("enemyatgates");
waitInt = setInterval(wait,5000, "enemyatgates");
btnBack.onPress = function () { // When button is pressed
gotoAndPlay("menu") // Go to Menu screen
enemyatgates.fadeToStop(0,4000); // fade volume from 100 to 0 over 4 seconds and stop sound.
fromintro = false;