# Sound Actionscript Error

**URL:** https://forum.kirupa.com/t/sound-actionscript-error/251292
**Category:** flash
**Created:** [February 6, 2008, 11:15pm UTC](https://forum.kirupa.com/t/sound-actionscript-error/251292 "2008-02-06T23:15:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![modermo](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@modermo](https://forum.kirupa.com/u/modermo)
#### Post date: [February 6, 2008, 11:15pm UTC](https://forum.kirupa.com/t/sound-actionscript-error/251292/1 "2008-02-06T23:15:42Z")

</div>

Hi

new to this forum. glad something is around to help newbies out.

ok, so heres my problem.

I have added sound to my animation using actionscript 2.0

When I click on the button to pause the song, I click it once:nothing, I click it again and then it stops.

When I then click the button to restart the music (from where it left off when I paused it) it starts again. I will then press stop (and it will stop) and press it again after that, and only then will it start playing from where I left off.

So here in a nutshell:  
(Song automatically starts)  
1st click: nothing  
2nd click: stops music  
3rd click: Music starts again, but from the beginning  
4th Click: Music stops  
5th Click: Music resides from where I stopped/paused it.

How do I just get a clean pause/start button?

Here is my actionscript.

var song:Sound = new Sound();  
var songPosition:Number = 0;  
song.attachSound(“number\_cruncher”);  
song.start();

btn\_sound.onRelease = function () {  
if (paused == true) {  
paused=false;  
songPosition = song.position/1000;  
song.stop();  
}  
else {  
paused = true;  
song.start(songPosition);  
}

}

var paused:Boolean = false;
