# Actionscript Sound Toggle

**URL:** <https://forum.kirupa.com/t/actionscript-sound-toggle/15673>\
**Category:** flash\
**Created:** [March 17, 2003, 12:43am UTC](https://forum.kirupa.com/t/actionscript-sound-toggle/15673 "2003-03-17T00:43:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shiek739](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Shiek739](https://forum.kirupa.com/u/Shiek739)\
**Post date:** [March 17, 2003, 12:43am UTC](https://forum.kirupa.com/t/actionscript-sound-toggle/15673/1 "2003-03-17T00:43:11Z")

</div>

Ok, I’m brain dead.  
That out of the way…

I’ve looked at all the messages in the forums and the tutorials.  
I used [http://www.kirupa.com/developer/actionscript/sound.htm](http://www.kirupa.com/developer/actionscript/sound.htm)  
tutorial and made a working button to START the sound. This method is the simplest. Can’t stop the sound yet.

Given that tutorial, what’s the simplest way to complete the audio toggle on/off task?

I don’t need anything elaborate. Just the basic toggle button.

Thanks all

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 17, 2003, 1:22am UTC](https://forum.kirupa.com/t/actionscript-sound-toggle/15673/2 "2003-03-17T01:22:18Z")

</div>

Got my act together.  
Works now. Figured it out on my own.

Modifies Kirupa’s code to read as follows:

on (release) {  
if(!music){  
music=true;  
kirupaSound = new Sound(this);  
kirupaSound.attachSound(“coolsound”);  
kirupaSound.start(0, 99);  
}  
else {  
music=false;  
stopAllSounds();  
}  
}

Works fine!!

Thanks Kirupa.
