# Sound only plays when clicking on pause button

**URL:** https://forum.kirupa.com/t/sound-only-plays-when-clicking-on-pause-button/295665
**Category:** flash
**Created:** [September 2, 2009, 6:35pm UTC](https://forum.kirupa.com/t/sound-only-plays-when-clicking-on-pause-button/295665 "2009-09-02T18:35:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![inspired78](https://avatars.discourse-cdn.com/v4/letter/i/9de0a6/32.png) [@inspired78](https://forum.kirupa.com/u/inspired78)
#### Post date: [September 2, 2009, 6:35pm UTC](https://forum.kirupa.com/t/sound-only-plays-when-clicking-on-pause-button/295665/1 "2009-09-02T18:35:25Z")

</div>

Hi

All my sounds work however, the play button only seems to play my sound when I click on the pause or stop button first!  
Plus, my stop button acts like a pause button, it doesn’t start the song from the beginning once it stops.  
Not sure why…  
Any ideas?

```auto
var mySound:Sound = new Sound(); 
var myChannel:SoundChannel = new SoundChannel(); 
var lastPosition:Number = 0; // pause button
var soundIsPlaying:Boolean = true; //NEW BOOLEAN TO CHECK
mySound.load(new URLRequest("that_tune.mp3")); //loads external sound file
//mySound.play();
myChannel = mySound.play(); 
stop_but.addEventListener(MouseEvent.CLICK, onClickStop);
function onClickStop(e:MouseEvent):void{
myChannel.stop();
soundIsPlaying = false; //NEW BOOLEAN TO CHECK
} 
play_but.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void{
if(!soundIsPlaying){ // NEW BOOLEAN TO CHECK
myChannel = mySound.play(lastPosition); // NEW BOOLEAN TO CHECK
soundIsPlaying = true; // NEW BOOLEAN TO CHECK
}
}
pause_but.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
soundIsPlaying = false; // NEW BOOLEAN TO CHECK
}
if( soundIsPlaying == true ) { 
lastPosition = myChannel.position;
myChannel.stop();
}

```
