michanagel
Technical User
Hi everybody,
I have weird sound issues over here that I can't seem to figure out...
I use an Interval to fade in a specific sound with this code:
Code:
_root.sound_theatre = new Sound(sound_theatre_mc);
_root.sound_theatre.attachSound("sound_theatre");
_root.sound_theatre.start(0, 1000000);
level = 0;
_root.sound_theatre.setVolume(level);
var level_in_interval:Number = setInterval(fadeInSound, 10, _root.sound_theatre);
// this is the sound fade in function
function fadeInSound():Void {
level += 1;
_root.sound_theatre.setVolume(level);
if (level == 100) {
clearInterval(level_in_interval);
}
}
Now when the user presses a specific button, the sound is supposed to fade out with this code (that is assigned to a keyframe on timeline where the movie jumps to when the user presses that specific button):
Code:
var level_out_interval:Number = setInterval(fadeOutSound, 10, _root.sound_theatre);
function fadeOutSound():Void {
level -= 1;
_root.sound_theatre.setVolume(level);
if (level == 100) {
clearInterval(level_out_interval);
}
}
Problem is: when the user presses that button very quickly - before the first interval is finished - the second interval runs through and fades out the music, but then still the first interval fades in the music again...
How can I kill that first Interval / function while it's still in process ?
Are there any other options to fade in a soundfile via actionscript besides the interval option ?
Thanx for your help in advance !!
Mike
I have weird sound issues over here that I can't seem to figure out...
I use an Interval to fade in a specific sound with this code:
Code:
_root.sound_theatre = new Sound(sound_theatre_mc);
_root.sound_theatre.attachSound("sound_theatre");
_root.sound_theatre.start(0, 1000000);
level = 0;
_root.sound_theatre.setVolume(level);
var level_in_interval:Number = setInterval(fadeInSound, 10, _root.sound_theatre);
// this is the sound fade in function
function fadeInSound():Void {
level += 1;
_root.sound_theatre.setVolume(level);
if (level == 100) {
clearInterval(level_in_interval);
}
}
Now when the user presses a specific button, the sound is supposed to fade out with this code (that is assigned to a keyframe on timeline where the movie jumps to when the user presses that specific button):
Code:
var level_out_interval:Number = setInterval(fadeOutSound, 10, _root.sound_theatre);
function fadeOutSound():Void {
level -= 1;
_root.sound_theatre.setVolume(level);
if (level == 100) {
clearInterval(level_out_interval);
}
}
Problem is: when the user presses that button very quickly - before the first interval is finished - the second interval runs through and fades out the music, but then still the first interval fades in the music again...
How can I kill that first Interval / function while it's still in process ?
Are there any other options to fade in a soundfile via actionscript besides the interval option ?
Thanx for your help in advance !!
Mike