# Sound problem

**URL:** <https://forum.kirupa.com/t/sound-problem/205057>\
**Category:** Uncategorized\
**Created:** [October 25, 2006, 6:52pm UTC](https://forum.kirupa.com/t/sound-problem/205057 "2006-10-25T18:52:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 6:52pm UTC](https://forum.kirupa.com/t/sound-problem/205057/1 "2006-10-25T18:52:22Z")

</div>

Hey, ive been looking around for some tutorials on this, but all i can find is tutorials on how to play sound,

I have this ambient sound that i want to start upp with the site, no problem.  
But i cant get it to stop playing, I need to have a button to stop and then start the sound loop again. It should be pretty basic i think.

Anyone know what to do?

Help much apretiated. 😃

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 7:37pm UTC](https://forum.kirupa.com/t/sound-problem/205057/2 "2006-10-25T19:37:06Z")

</div>

You need to include a stopAllSounds on your button, e.g.

```auto
stop_btn.onRelease = function() {
 stopAllSounds();
};

```

To start your sounds using a button, you’d need to link the sound from your library first. Then, again within the button handler, create a sound object and attach the linked sound to it. This tutoiral should help you out [http://www.kirupa.com/developer/actionscript/sound.htm](http://www.kirupa.com/developer/actionscript/sound.htm)

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 8:23pm UTC](https://forum.kirupa.com/t/sound-problem/205057/3 "2006-10-25T20:23:51Z")

</div>

Sweet thx man. Got it working now. 😃

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 8:26pm UTC](https://forum.kirupa.com/t/sound-problem/205057/4 "2006-10-25T20:26:16Z")

</div>

Well done 🙂

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 8:49pm UTC](https://forum.kirupa.com/t/sound-problem/205057/5 "2006-10-25T20:49:35Z")

</div>

Another thing, is there anyway i can get it to fade in at the start of the movie, and when i press the play button.

Code as it is now:

```auto
	kirupaSound = new Sound(this);
	kirupaSound.attachSound("forest");
	kirupaSound.start(0, 999);

```

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 9:05pm UTC](https://forum.kirupa.com/t/sound-problem/205057/6 "2006-10-25T21:05:06Z")

</div>

You can use the sound.SetTransform method if you want to do it wholly in Actionscript. check out the Help file for more details.

Alternatively, if you just want a simple fade, select the frame containing your sound and then choose Fade In underthe Effects dropdown. You can also Edit the sound, then click along the wavelength to add your own effects.

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 9:35pm UTC](https://forum.kirupa.com/t/sound-problem/205057/7 "2006-10-25T21:35:26Z")

</div>

Yeah, but with the action script im using now, im getting the loop file directly from to library. And i didnt find a place where i could add fade in effect directly on the library file.

So ill probably have to action script the fade in then? 🙂

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 9:43pm UTC](https://forum.kirupa.com/t/sound-problem/205057/8 "2006-10-25T21:43:38Z")

</div>

Have a read of this  
[http://www.actionscript.org/resources/articles/119/1/Dynamic-Sound-Fade/Page1.html](http://www.actionscript.org/resources/articles/119/1/Dynamic-Sound-Fade/Page1.html)

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 10:02pm UTC](https://forum.kirupa.com/t/sound-problem/205057/9 "2006-10-25T22:02:51Z")

</div>

Nice tutorial. 🙂

I followed the steps but for some reason it wont play the sound?

```auto
music = new Sound();
music.attachSound("forest");
music.start(0, 999999);
music.setVolume();
vol = 0;
fade = setinterval(fadeIn, 100);
function fadeIn() {
        vol += 5;
        music.setVolume(vol);
        if (vol>=100) {
                clearInterval(fade);
                step = 1;
                Fade = 0;
        }
}
_root.onEnterFrame = function() {
        if (Fade == 1) {
                vol = vol-step;
                if (vol<0) {
                        vol = 0;
                }
                music.setVolume(vol);
        } else {
                vol = vol+step;
                if (vol>100) {
                        vol = 100;
                }
                music.setVolume(vol);
        }
};

```

I cant really see why it shoudnt work.

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 10:11pm UTC](https://forum.kirupa.com/t/sound-problem/205057/10 "2006-10-25T22:11:59Z")

</div>

Do you have the fla?

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 10:15pm UTC](https://forum.kirupa.com/t/sound-problem/205057/11 "2006-10-25T22:15:38Z")

</div>

Well, I just copied that code into the first frame (didn’t bother with a button) and it fades in just fine.

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 10:21pm UTC](https://forum.kirupa.com/t/sound-problem/205057/12 "2006-10-25T22:21:21Z")

</div>

Here is the fla. file

**Sound test.fla**

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 10:22pm UTC](https://forum.kirupa.com/t/sound-problem/205057/13 "2006-10-25T22:22:07Z")

</div>

Hmmm wonder why mine doesnt work.

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 10:29pm UTC](https://forum.kirupa.com/t/sound-problem/205057/14 "2006-10-25T22:29:13Z")

</div>

It works fine…but it’s very very faint…maybe you need to turn your speakers up? 🙂

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 10:42pm UTC](https://forum.kirupa.com/t/sound-problem/205057/15 "2006-10-25T22:42:05Z")

</div>

hehehe, thats soo wierd. Cause when i play it, nothing. i have my speakers on full too. :ear:

if i try to remove the fade code and just play the file itself it works fine.  
I love it when this happens, 😃 a mystery

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 10:44pm UTC](https://forum.kirupa.com/t/sound-problem/205057/16 "2006-10-25T22:44:30Z")

</div>

Actually, I’ve solved the mystery - I’m playing your fla in Flash 6 😃

I’ll play some more and see what I can come up with

---

<div class="post-metadata">

**Author:** ![m\_h\_w](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@m\_h\_w](https://forum.kirupa.com/u/m_h_w)\
**Post date:** [October 25, 2006, 11:06pm UTC](https://forum.kirupa.com/t/sound-problem/205057/17 "2006-10-25T23:06:32Z")

</div>

Oh cool, Thx alot! :beam:

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [October 25, 2006, 11:25pm UTC](https://forum.kirupa.com/t/sound-problem/205057/18 "2006-10-25T23:25:10Z")

</div>

```auto
music = new Sound();
music.attachSound("forest");
music.start(0);
music.setVolume(0);
vol = 0;
fade = setInterval(fadeIn, 100);
function fadeIn() {
        vol += 1;
        music.setVolume(vol);
        if (vol>=100) {
                clearInterval(fade);
        }
}

```

You didn’t need all of that onEnterFrame gibberish and setinterval should be setInterval (since AS2 is case-sensitive).

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [October 25, 2006, 11:45pm UTC](https://forum.kirupa.com/t/sound-problem/205057/19 "2006-10-25T23:45:04Z")

</div>

Thanks…we got there in the end 🙂

■■■■ example was riddled with spelling inconsistencies!! Gibberish was the polite word.

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [October 25, 2006, 11:49pm UTC](https://forum.kirupa.com/t/sound-problem/205057/20 "2006-10-25T23:49:00Z")

</div>

Three minds are better than two 😛

Just noticed that you’ll need to put the loops argument back into the start method.
