# Music Button newbie question

**URL:** https://forum.kirupa.com/t/music-button-newbie-question/301336
**Category:** flash
**Created:** [December 7, 2009, 10:42pm UTC](https://forum.kirupa.com/t/music-button-newbie-question/301336 "2009-12-07T22:42:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![johnnien](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@johnnien](https://forum.kirupa.com/u/johnnien)
#### Post date: [December 7, 2009, 10:42pm UTC](https://forum.kirupa.com/t/music-button-newbie-question/301336/1 "2009-12-07T22:42:25Z")

</div>

Do you guys know a nice tutorial about a music button in AS 3? I already have this file from another thread here, where a sound button is made on a single frame and the code goes like this:  
import flash.media.Sound;  
import flash.media.SoundChannel;

var soundOn:Boolean = true; //music is ON when we start  
var myMusic:TitleMusic = new TitleMusic();  
var myChannel:SoundChannel = myMusic.play(0,1000); // endless loop, in effect  
var myTransform:SoundTransform;

mySoundButton.addEventListener(MouseEvent.CLICK,toggleSound);  
mySoundButton.buttonMode = true;  
mySoundButton.mouseChildren = false;

function toggleSound(e:MouseEvent)  
{  
if(soundOn)  
{  
// turn sound off  
myTransform = new SoundTransform();  
myTransform.volume = 0; // silent  
myChannel.soundTransform = myTransform;  
soundOn = false;  
mySoundButton.myButtonText.text = “click to turn sound ON”;  
}  
else // sound is off  
{  
// turn sound on  
myTransform = new SoundTransform();  
myTransform.volume = 1; // full volume  
myChannel.soundTransform = myTransform;  
soundOn = true;  
mySoundButton.myButtonText.text = “click to turn sound OFF”;  
}

}  
The problem is that I want to gave NO music at the start of the scene and when the button is pressed the music to start playing. What do I need to change here? Or i need to start the whole thing from scratch?  
I have attached the file … Thanks!
