clintnash
asked on
Sound - crossfade between two loops
I have an simple banner flash, It has a loop that plays through the first part 3/4 of the animation, at that point, I want to fade out the first loop while fading in the other. I have managed to accomplish a fade out using.
firstSound.setVolume(15);
and decreasign the volume in a series of keyframes, however when I try to add get the other loop to start fading in before the other is done, its just doesn't work.
In the first frame of a layer called Sound level 1 I call this.
firstSound=new Sound();
firstSound.attachSound("02 74Full");
firstSoundVolume=100;
firstSound.setVolume(first SoundVolum e);
In the second frame of a seperate layer called background I call this...
if (playing!=true) {
_root.firstSound.start(0,9 99);
playing=true;
}
This works just fine, In a 3rd layer called Sound Level 2 I tried changing the attached sound like so..
firstSound=new Sound();
firstSound.attachSound("01 66Full");
firstSoundVolume=0;
And then in the 1st layer bring the volume back up, that didn't work, nor did creating a new layer and creating a new sound object call secondSound...
any advice on smoothly transitioning between loops is greatly appreciated, my experience level is slightly above beginner.
thanks,
clint...
firstSound.setVolume(15);
and decreasign the volume in a series of keyframes, however when I try to add get the other loop to start fading in before the other is done, its just doesn't work.
In the first frame of a layer called Sound level 1 I call this.
firstSound=new Sound();
firstSound.attachSound("02
firstSoundVolume=100;
firstSound.setVolume(first
In the second frame of a seperate layer called background I call this...
if (playing!=true) {
_root.firstSound.start(0,9
playing=true;
}
This works just fine, In a 3rd layer called Sound Level 2 I tried changing the attached sound like so..
firstSound=new Sound();
firstSound.attachSound("01
firstSoundVolume=0;
And then in the 1st layer bring the volume back up, that didn't work, nor did creating a new layer and creating a new sound object call secondSound...
any advice on smoothly transitioning between loops is greatly appreciated, my experience level is slightly above beginner.
thanks,
clint...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is how to fade the first sound and make the second fade in as soon as the first finishes fading out:
First Frame Actions:
vol1 = 100;
vol2 = 0;
speed = 2; // The higher the number, the faster the transition
firstSound = new Sound();
firstSound.attachSound("02
secondSound = new Sound();
secondSound.attachSound("0
function fadeOut() {
vol1 -= speed;
firstSound.setVolume(vol1)
if (vol1 <= 0) {
done = 1;
firstSound.setVolume(0);
firstSound.stop();
secondSound.start(0, 9999);
secondSound.setVolume(0);
clearInterval(fade1);
}
}
function fadeIn() {
if (done == 1) {
vol2 += speed;
secondSound.setVolume(vol2
if (vol2 >= 100) {
secondSound.setVolume(100)
clearInterval(fade2);
}
}
}
function startFirstSound() {
firstSound.start(0, 9999);
firstSound.setVolume(100);
}
startFirstSound();
Then on the timeline where you want the fade out to begin:
fade1 = setInterval(fadeOut, 100);
fade2 = setInterval(fadeIn, 100);
If the transition is too slow, adjust the speed variable to a higher number.
-Sam