# Sound queastion

**URL:** <https://forum.kirupa.com/t/sound-queastion/299902>\
**Category:** flash\
**Created:** [November 12, 2009, 11:55am UTC](https://forum.kirupa.com/t/sound-queastion/299902 "2009-11-12T11:55:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daimz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/daimz/32/2383_2.png) [@Daimz](https://forum.kirupa.com/u/Daimz)\
**Post date:** [November 12, 2009, 11:55am UTC](https://forum.kirupa.com/t/sound-queastion/299902/1 "2009-11-12T11:55:50Z")

</div>

I am trying to add a sound loop to my site and I have managed to get the sound to play and I can make two buttons start and stop. But how can I make 1 button that both starts and stops the sound?

Here What I have got.

```auto

var snd:Sound = new Sound(new URLRequest("dub.mp3"));
var channel:SoundChannel = snd.play();
var pausePosition:int = channel.position;
var volum:Number=0.2;
var transf:SoundTransform = new SoundTransform();

function setVolume(vol:Number):void {
    transf.volume=vol;
    channel.soundTransform=transf;
}

setVolume(volum);

function stopSound(event:MouseEvent):void {
channel.stop();
channel = null;
}

mute.addEventListener(MouseEvent.CLICK, stopSound);

function startSound(event:MouseEvent):void {
    
    if (channel == null)
{
channel = snd.play(pausePosition);

}
                         

}

mute.addEventListener(MouseEvent.CLICK, startSound);

```
