# Attach sound problem

**URL:** https://forum.kirupa.com/t/attach-sound-problem/29017
**Category:** flash
**Created:** [August 21, 2003, 4:59am UTC](https://forum.kirupa.com/t/attach-sound-problem/29017 "2003-08-21T04:59:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![arturziyalov](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@arturziyalov](https://forum.kirupa.com/u/arturziyalov)
#### Post date: [August 21, 2003, 4:59am UTC](https://forum.kirupa.com/t/attach-sound-problem/29017/1 "2003-08-21T04:59:01Z")

</div>

I am having problems playing my loop i have a play and stop button my movie is 1 keyframe long.

On frame one I have the following actionscript:

mySound = new Sound();  
mySound.attachSound(“bgSound”);  
mySound.start(0, 999);  
// loop 999 times

On the ON button I have

on (release) {  
if (playing != true) {  
mySound.start(0, 999);  
playing = true;  
}  
}

On the OFF Button I have

on (release) {  
mySound.stop();  
}

There are 2 problems, when I stop and play the sound 2 times after 2 times it wont play.

The other problem happens when I press on play it plays on top of the sound and messes it up completely, can anyone correct the actionscript so it wont play on top of the sound, and it will play everytime the user clicks stop and play. Im posting the SWF File so you will get a picture of what I mean. Thanks alot for your help.

[http://www.artek-design.com/sound.swf](http://www.artek-design.com/sound.swf)

---

<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: [August 21, 2003, 5:07am UTC](https://forum.kirupa.com/t/attach-sound-problem/29017/2 "2003-08-21T05:07:43Z")

</div>

[AS]mySound = new Sound();  
mySound.attachSound(“bgSound”);  
mySound.start(0, 999);  
playing = true;  
//  
on (release) {  
if (!playing) {  
mySound.start(0, 999);  
playing = true;  
}  
}  
//  
on (release) {  
if (playing) {  
mySound.stop();  
playing = false;  
}  
}[/AS]

---

<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: [August 21, 2003, 5:10am UTC](https://forum.kirupa.com/t/attach-sound-problem/29017/3 "2003-08-21T05:10:15Z")

</div>

OK THanks Kax got it.

---

<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: [August 21, 2003, 5:14am UTC](https://forum.kirupa.com/t/attach-sound-problem/29017/4 "2003-08-21T05:14:37Z")

</div>

You’re welcome. =)
