Stopping sound on roll out

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:

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) {;
on (rollOut) {

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


ooooooh !! cool ! thanks !!! :slight_smile:

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


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();

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.


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);

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();


thanks a lot for your time guys… i really appreciate it :slight_smile:

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

have you tried…
on (rollOver) {
_root.heartbeat.start(0, 5);

or what ever the path to your sound is…?

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