So I’ve got this script:
[AS]stop();
// initiate sound
music = new Sound();
music.attachSound(“backsound”);
music.start(0, 999999);
// set the volume of the sound to zero
music.setVolume(0);
// set a variable named ‘vol’
vol = 0;
// 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 += 3;
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);
}
};
[/AS]
…and it works great when I don’t use onEnterFrame, but then shortly after it goes crazy and rips my speakers to shreds. So I need onEnterFrame to prevent that and to keep my button working. Sadly onEnterFrame makes the whole script not work
What do I do?
Thanks in Advance!