# Creating a sound button that when clicked starts or stops the music

**URL:** https://forum.kirupa.com/t/creating-a-sound-button-that-when-clicked-starts-or-stops-the-music/66074
**Category:** flash
**Created:** [October 2, 2004, 5:48am UTC](https://forum.kirupa.com/t/creating-a-sound-button-that-when-clicked-starts-or-stops-the-music/66074 "2004-10-02T05:48:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![innoxist](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@innoxist](https://forum.kirupa.com/u/innoxist)
#### Post date: [October 2, 2004, 5:48am UTC](https://forum.kirupa.com/t/creating-a-sound-button-that-when-clicked-starts-or-stops-the-music/66074/1 "2004-10-02T05:48:19Z")

</div>

Instead of using 2 buttons to start or stop the music, is it possible to just use one? So when the music is playing, click it and it’ll stop, but when the music is stopped, on clicking, it will start.

---

<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: [October 2, 2004, 6:41am UTC](https://forum.kirupa.com/t/creating-a-sound-button-that-when-clicked-starts-or-stops-the-music/66074/2 "2004-10-02T06:41:03Z")

</div>

> [@innoxist](#):
>
> Instead of using 2 buttons to start or stop the music, is it possible to just use one? So when the music is playing, click it and it’ll stop, but when the music is stopped, on clicking, it will start.

// on the timeline containing mySound = new Sound(), button instance name myButton  
myButton.onRelease = function() {  
(playing=!playing) ? mySound.start() : mySound.stop();  
};

---

<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: [October 2, 2004, 2:14pm UTC](https://forum.kirupa.com/t/creating-a-sound-button-that-when-clicked-starts-or-stops-the-music/66074/3 "2004-10-02T14:14:10Z")

</div>

In addition, I cover that in my tutorial if you want to read that too. See sig.
