# Control sound through actionscript 2

**URL:** https://forum.kirupa.com/t/control-sound-through-actionscript-2/321201
**Category:** Uncategorized
**Created:** [April 13, 2011, 10:52am UTC](https://forum.kirupa.com/t/control-sound-through-actionscript-2/321201 "2011-04-13T10:52:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![infyx](https://avatars.discourse-cdn.com/v4/letter/i/6de8d8/32.png) [@infyx](https://forum.kirupa.com/u/infyx)
#### Post date: [April 13, 2011, 10:52am UTC](https://forum.kirupa.com/t/control-sound-through-actionscript-2/321201/1 "2011-04-13T10:52:13Z")

</div>

Hello all,

I am using this code to control a sort of interactive slideshow.  
I have an array which contains framelabels and when you press a button it moves on to the next framelabel

```auto

var labelArr:Array = ["frame1","frame2","frame3","frame4","frame5","frame6","frame7","frame8","frame1"]; 
var currentLabel:Number = 0;

next_btn.onRelease = function() {     
    if (currentLabel < labelArr.length - 1) {         
        currentLabel++;         
        gotoAndPlay(labelArr[currentLabel]);     
    }else{                 
        currentLabel = 0;         
        gotoAndStop(labelArr[currentLabel]);
    } 
}

```

What i want to do now is have sound fade in, loop while in “frame1” then fade out the sound from “frame1” and fade in the sound from “frame2” when the user clicks on the button to move on.

What i’ve tried doing this using

```auto

bgSound = new Sound(this);
bgSound.attachSound("bus_natural");
bgSound.start(0, 99);

```

to start the sound and then

```auto

this.onEnterFrame = function() {
    stopAllSounds();
}

```

to stop it. But i really need the fade in and out effect because the visual transition is gradual and the sound transition isn’t.

help 🙂
