# Controlling sounds

**URL:** <https://forum.kirupa.com/t/controlling-sounds/230932>\
**Category:** Uncategorized\
**Created:** [June 30, 2007, 6:01am UTC](https://forum.kirupa.com/t/controlling-sounds/230932 "2007-06-30T06:01:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![costa](https://avatars.discourse-cdn.com/v4/letter/c/85f322/32.png) [@costa](https://forum.kirupa.com/u/costa)\
**Post date:** [June 30, 2007, 6:01am UTC](https://forum.kirupa.com/t/controlling-sounds/230932/1 "2007-06-30T06:01:55Z")

</div>

Dear all,

I am trying to control a sound I am using as background. I got a button which I want to push to stop and play the music. I am not sure if next code is the right one to achieve this task

```auto
var channel:SoundChannel = mySound.play();
controlMusic (); //sound off
controlMusic (); //sound on

function controlMusic (){
	var transformSound:SoundTransform = channel.soundTransform
	if (transformSound.volume == 0){
		transformSound.volume =1;
		}
		else {
			  transformSound.volume = 0;
		}
	channel.soundTransform = transformSound;
}

```

I was looking for some way to detect if a sound is playing but I only got this volume idea

I will appreciate your feedback
