# Weird sound problem

**URL:** <https://forum.kirupa.com/t/weird-sound-problem/240005>\
**Category:** Uncategorized\
**Created:** [September 28, 2007, 2:51am UTC](https://forum.kirupa.com/t/weird-sound-problem/240005 "2007-09-28T02:51:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ultra](https://avatars.discourse-cdn.com/v4/letter/u/a587f6/32.png) [@Ultra](https://forum.kirupa.com/u/Ultra)\
**Post date:** [September 28, 2007, 2:51am UTC](https://forum.kirupa.com/t/weird-sound-problem/240005/1 "2007-09-28T02:51:12Z")

</div>

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:

```auto

_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):

```auto

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
