# Stopping sound on roll out

**URL:** <https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305>\
**Category:** Uncategorized\
**Created:** [December 20, 2003, 11:55pm UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305 "2003-12-20T23:55:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![doOfus](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@doOfus](https://forum.kirupa.com/u/doOfus)\
**Post date:** [December 20, 2003, 11:55pm UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/1 "2003-12-20T23:55:50Z")

</div>

hey… i tried searching the forum but couldnt find an answer to my problem…

ok, im making a button… and when you put the mouse over it, it plays a heart beat sound… and when you roll out, the heart beat stops…

but it doesnt stop !! lol does anyone know how to make the sound stop?? :red:

im using buttons… not mcs… :huh:

---

<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:** [December 21, 2003, 1:33am UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/2 "2003-12-21T01:33:31Z")

</div>

The way I have it you would put it in a frame on your main timeline where you have all of your actionscripts and you reference the button by its name.

If applying the rollovers to the actual button you could do this–(NOT in the button editors over state but on the actual button by clicking it one time with your mouse on the stage and opening the actions panel and putting the code in with expert mode.)

on (rollOver) {  
yourSound.play();  
}  
on (rollOut) {  
yourSound.stop();  
}

Here, yourSound is the name you have given your sound in your library.

–vagabond007

---

<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:** [December 21, 2003, 1:35am UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/3 "2003-12-21T01:35:46Z")

</div>

ooooooh !! cool ! thanks !!! 🙂

---

<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:** [December 21, 2003, 1:47am UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/4 "2003-12-21T01:47:20Z")

</div>

Whoops! Messed up a tad on the action that gets the sound to play…

sorry.

Here is the real code… my bad.

on (rollOver) {  
yourSound.start(0, 5);  
}

Here 0 is the amount of seconds that you want to pass before the sound starts playing and 5 equals the amount of times you want the sound to loop while playing. Change the 0 or 5 however you wish to do your playback.

.play() was my error.  
.start() is the correct way to trigger the sound to play.

You will probably want to do this in a frame on the timeline where you button is on another level.

yourSound = new Sound();  
yourSound.attachSound(“yourSoundsIDintheLibrary”);

This will create a new sound object with the name yourSound and attach it to the timeline’s frame. “yourSoundsIDintheLibrary” is just to be changed to the name of the sound sample as it appears in your object library.

–vagabond007

---

<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:** [December 21, 2003, 2:08am UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/5 "2003-12-21T02:08:32Z")

</div>

waaaaaa !! i stil cant get it to work !! :hair:

ok… uhm… what i understand is… you put this code on the button  
[instance name is ‘home’]

on (rollOver) {  
heartbeat.start(0, 5);  
}  
on(rollOut){  
heartbeat.stop();  
}

where ‘heartbeat’ is the name of the sound file… and it is also the ID… [is that ok? they have the same name…]

and i put this on the frame where the home button is

heartbeat = new Sound();  
heartbeat.attachSound(“heartbeat”);

???

thanks a lot for your time guys… i really appreciate 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:** [December 21, 2003, 2:17am UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/6 "2003-12-21T02:17:39Z")

</div>

make sure you go to your library, right click on your sound file and make sure the firts 2 checkboxes are ccheck and u gave the osudn the name heartbeat

---

<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:** [December 21, 2003, 2:24am UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/7 "2003-12-21T02:24:43Z")

</div>

have you tried…  
[AS]  
on (rollOver) {  
\_root.heartbeat.start(0, 5);  
}  
on(rollOut){  
\_root.heartbeat.stop();  
}  
[/AS]

or what ever the path to your sound is…?

---

<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:** [December 21, 2003, 4:16am UTC](https://forum.kirupa.com/t/stopping-sound-on-roll-out/38305/8 "2003-12-21T04:16:10Z")

</div>

yes !! it worked ! thank you guys!!! :love:
