# On/off music toggle

**URL:** https://forum.kirupa.com/t/on-off-music-toggle/52504
**Category:** Uncategorized
**Created:** [May 24, 2004, 6:58pm UTC](https://forum.kirupa.com/t/on-off-music-toggle/52504 "2004-05-24T18:58:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kranekick](https://avatars.discourse-cdn.com/v4/letter/k/b19c9b/32.png) [@kranekick](https://forum.kirupa.com/u/kranekick)
#### Post date: [May 24, 2004, 6:58pm UTC](https://forum.kirupa.com/t/on-off-music-toggle/52504/1 "2004-05-24T18:58:38Z")

</div>

i have been stuck with this for days so thought i’d try this forum.  
on the main timeline i’m trying to have an on/off music toggle button. here’s the code on the first frame:

[color=#003366]this.createEmptyMovieClip(“mcSoundHolder”, this.getNextHighestDepth());  
var sndAudio:Sound = new Sound(mcSoundHolder);[/color]  
[color=#003366]sndAudio.onLoad = function(bSucess:Boolean) {  
if(bSucess) {  
this.start();  
}  
}[/color]  
[color=#003366]mcAudioBtn.onRelease = function() {  
sndAudio.loadSound(“audio/music.mp3”, false);  
sndAudio.setVolume(100);  
sound = playing;  
if (sound==playing) {  
sndAudio.stop();  
playing = false;  
}  
if(sound!==playing) {  
sndAudio.start(0,9999);  
playing = true;  
}[/color]  
[color=#003366]};[/color]  
[color=#003366][/color]  
[color=#003366]whenever i click the toggle button it restarts the sound and downloads it again. can anyone tell me where my code is wrong or what i have to add?[/color]
