[font=verdana, arial, helvetica][size=2][color=#4f5044]I followed the tutorial that was recommended on Flashkit.com for the toggle button with sound fade and it worked great. However, I have a little problem. I created a website entirely in Flash, but rather than create a single navigation with a container MC and then load mc for each page, I created one MC with scenes for each page. (I haven’t quite mastered the single nav thing yet…baby steps.) So I have my music clip loading on the intro animation and then the site loads and the music plays continually. I have placed the sound button on each page, so when you click the button, the music fades out. I altered the script so that the volume would be 100 and not 0, but that doesn’t seem to be the problem. When you click on another page, the music is playing up full again. I need the sound clip to only play (or not play) if the button is clicked. Given the way my site is built, is this possible? Perhaps there should be an If- Then code to see if the music is playing or not. Any help is appreciated. Here is the code as I have it on each page.
var s = 1;
// initiate sound
music = new Sound();
music.attachSound(“firstsound”);
music.start(0, 999999);
// set the volume of the sound to zero
music.setVolume(100);
// set a variable named ‘vol’
vol = 100;
// set another variable named ‘fade’, putting a setInterval function in it
fade = setInterval(fadeIn, 100);
// set the initial fade in function
function fadeIn() {
// fade the sound in with an increment of 3 in the variable ‘vol’
vol += 20;
music.setVolume(vol);
// put an if condition to restrict the increment in volume after it reaches to 100
if (vol>=100) {
clearInterval(fade);
// create the ‘step’ variable
step = 1;
// create the ‘fade’ variable
Fade = 0;
}
}
// create the fade in and out function
// function executed on onEnterFrame
_root.onEnterFrame = function() {
// set fade out
if (Fade == 1) {
vol = vol-step;
if (vol<0) {
vol = 0;
}
music.setVolume(vol);
// set fade in
} else {
vol = vol+step;
if (vol>100) {
vol = 100;
}
music.setVolume(vol);
}
};
Thanks for any help or ideas.[/color][/size][/font]