Fade sound in and out from different level... help!

Hi everybody,

I’m working on this new project:

background music level 20, with a speaker mc which toggles:
frame 1 music on
frame 2 music off

video gallery - level 10

What I want to do is:
when the video gallery loads, background sound to fade out and speaker mc to toggle off.
when video gallery unloads, background sound to fade in and speaker mc to toggle on.

There’s some code I found here (stringy) to fade in and fade out, it works perfectly with the background music and the speaker mc but can’t make it to work from another another level…

I can stop and start the sound using:

_level20.myMusic.stop();
_level20.myMusic.start(0, 999999);

but I would like to make it fade, here’s the code:

music = new Sound(this);
music.attachSound("mysound");
music.start(0, 999999);
//
music.setVolume(0);
// 
vol = 0;
fade = 0;
// 
Fade = setInterval(fadeIn, 100);
// 
function fadeIn() {
	vol += 10;
	music.setVolume(vol);
	if (vol>=100) {
		clearInterval(Fade);
		step = 1;
		fade = 0;
		f();
	}
}
//
fadeIn();
function f() {
	_root.onEnterFrame = function() {
		// set fade out
		if (fade == 1) {
			vol = vol-step;
			if (vol<0) {
				vol = 0;
			}
			music.setVolume(vol);
			// set fade in
			boton.gotoAndStop(2);
		} else {
			vol = vol+step;
			if (vol>100) {
				vol = 100;
			}
			music.setVolume(vol);
			boton.gotoAndStop(1);
		}
	};
}
//
speaker.onRelease = function() {
	(_root.fade=!_root.fade) ? 0 : 1;
};

wish somebody can help me!
thanks in advanced!
:slight_smile: