# Making a sound loop?

**URL:** <https://forum.kirupa.com/t/making-a-sound-loop/14562>\
**Category:** flash\
**Created:** [February 27, 2003, 8:44pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562 "2003-02-27T20:44:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neuhaus3000](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/neuhaus3000/32/168_2.png) [@Neuhaus3000](https://forum.kirupa.com/u/Neuhaus3000)\
**Post date:** [February 27, 2003, 8:44pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/1 "2003-02-27T20:44:12Z")

</div>

Hello Everyone,

I have a script on a button…  
When I rollOver, the sound starts.  
When I rollOut, the sound stops.

But what could I add to make the  
sound loop until I rollOut?

Here’s the script on my button…

* * *

on (rollOver) {  
myMusic = new Sound(this);  
myMusic.attachSound(“sound\_effect”);  
myMusic.start();  
}

on (rollOut) {  
myMusic.stop();  
}

* * *

Thanks!  
Neuhaus3000

---

<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:** [February 27, 2003, 8:50pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/2 "2003-02-27T20:50:30Z")

</div>

add the **loop** parameter in this line:

```auto
myMusic.start(secondsoffset, loop);

```

something like

```auto
myMusic.start(0, 999);

```

would do 🙂

---

<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:** [February 27, 2003, 8:53pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/3 "2003-02-27T20:53:20Z")

</div>

Dude, your fast !

Thanks… I will try this.  
I’m sure it will work !

Have a nice day! :beam:

Neuhaus3000

---

<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:** [February 27, 2003, 8:58pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/4 "2003-02-27T20:58:28Z")

</div>

no problem neuhaus =)

and nice day to you too 😉

---

<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:** [February 27, 2003, 8:58pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/5 "2003-02-27T20:58:59Z")

</div>

Works fine for the looping ! =)

But on rollout, it doesn’t stop… :x

Is this code ok ? I think so…

on (rollOut) {  
myMusic.stop();  
}

I also noticed that when I use  
actionScript to open a sound,  
It appears louder !.. What the ?!? 😠

Neuhaus3000

---

<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:** [February 27, 2003, 9:21pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/6 "2003-02-27T21:21:43Z")

</div>

:stunned:

can you attach your fla ?

and if you don’t want it that louder …

```auto
myMusic.setVolume(volume);

```

---

<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:** [February 28, 2003, 2:06pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/7 "2003-02-28T14:06:59Z")

</div>

Hey Kax,

Attach my fla ?

I can attach the sound symbol from the library.  
But I can’t make it stop with this script :

on (rollOut) {  
myMusic.stop();  
}

Thanks for the volume script! :beam:

Neuhaus3000

---

<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:** [February 28, 2003, 2:37pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/8 "2003-02-28T14:37:07Z")

</div>

😛

attach your fla file in your post 😉

i don’t know why it’s not working … that’s why i’d like to see your file 🙂

---

<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:** [February 28, 2003, 3:36pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/9 "2003-02-28T15:36:41Z")

</div>

u can try  
myMusic.stop(“sound\_effect”);

---

<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:** [February 28, 2003, 4:59pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/10 "2003-02-28T16:59:41Z")

</div>

Hey Eudora, thanks for the tip! 😏  
This is logical and it should work…  
but it doesn’t :-\

The volume doesn’t work either. :sleep:

This is what I’ve got :

* * *

on (rollOver) {  
myMusic = new Sound(this);  
myMusic.attachSound(“sound\_effect”);  
myMusic.start(0, 999);  
myMusic.setVolume(50);  
}

on (rollOut) {  
myMusic.stop(“sound\_effect”);  
}

* * *

Man, I tell ya… :sigh: Everything seems to be  
in the right place.

Any clue ? I will make some more tests tonight. :hangover:

Thank you all !!!  
Neuhaus3000

---

<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:** [February 28, 2003, 5:23pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/11 "2003-02-28T17:23:36Z")

</div>

```auto
on (rollOver) {
	myMusic = new Sound(this);
	myMusic.attachSound("sound_effect");
	myMusic.setVolume(50);
	myMusic.start(0, 999);
}
on (rollOut) {
	myMusic.stop();
}

```

weird … i just tested it and everything worked perfectly :-\

---

<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:** [March 3, 2003, 3:26pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/12 "2003-03-03T15:26:41Z")

</div>

It worked! :crazy:

I ajusted a couple of things…

- Deleted the audio in my “Over” button state (settled the volume problem); :sigh:
- Disabled the linkage “add in 1st frame” and added the sounds in blank frames (settled the long 1 frame downloading); 😛

Many Thanks !!! 🙂

Neuhaus3000

## code:

## on (rollOver) { myMusic = new Sound(this); myMusic.attachSound(“sound\_effect”); myMusic.setVolume(50); myMusic.start(0, 999); } on (rollOut) { myMusic.stop(); }

---

<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:** [March 3, 2003, 3:35pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/13 "2003-03-03T15:35:59Z")

</div>

no problem **neuhaus** =)

glad it worked 🙂 😉

---

<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:** [March 3, 2003, 4:05pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/14 "2003-03-03T16:05:56Z")

</div>

🙂

I have on other bug that I can’t quite get an answer…

I’m loading a movie above an other one  
but the the buttons on the movie underneath  
are still active. Do you know how to disable them?  
:crazy:

Thanks!

Neuhaus3000

---

<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:** [March 3, 2003, 4:16pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/15 "2003-03-03T16:16:24Z")

</div>

\<a href=“[http://www.kirupaforum.com/search.php?s=](http://www.kirupaforum.com/search.php?s=)”\>  
\<img border=“0” src=“[http://www.kirupaforum.com/images/search\_top.gif](http://www.kirupaforum.com/images/search_top.gif)” width=“56” height=“18”\>\</a\> 😉

```auto
MovieClip.prototype.enable = function(action) {
	for (k in this) {
		this[k].enabled = action;
	}
}
// to enable
instance.enable(true);
// to disable
instance.enable(false);

```

**instance** can be a movie clip if you’re loading into target or a level 🙂

---

<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:** [March 3, 2003, 4:17pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/16 "2003-03-03T16:17:42Z")

</div>

btuttonname.enabled=false

Grim

---

<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:** [March 3, 2003, 4:35pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/17 "2003-03-03T16:35:06Z")

</div>

Hey Kax,

Wooooohooo ! =)

But I can’t quite seem to know how to add the script  
to my movie… :nerd:

I have a main movie (level0) that loads a movie on level 1.  
On my level 1, I have a button that loads a movie  
on level 2.

I want to disable only my buttons on level 1  
when the movie on level 2 has loaded and  
when I unload the movie on level 2, I want  
my buttons to be enabled again :crazy:

## Structure

Level\_0 (main movie)  
|  
Level\_1 (movie where my buttons are and should be disabled)  
|  
Level\_2 (when I unload this movie, I should enable  
my buttons on level\_1 again)

* * *

So I have to add the script where exactly ? ;(

Thanks a million !!! 🙂  
Neuhaus3000

---

<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:** [March 3, 2003, 4:41pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/18 "2003-03-03T16:41:17Z")

</div>

you would have

```auto
_level1.enable(false);

```

in the first frame of the movie loaded at level 2

when you unload the movie just use

```auto
_level1.enable(true);

```

and your buttons will recover its functionality 🙂

---

<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:** [March 3, 2003, 4:52pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/19 "2003-03-03T16:52:07Z")

</div>

## And …

## MovieClip.prototype.enable = function(action) { for (k in this) { this[k].enabled = action; } }

…would go on the button that calls the movie on level2… right?

## It would look like :

## on (release) { MovieClip.prototype.enable = function(action) { for (k in this) { this[k].enabled = action; } } }

Neuhaus3000

---

<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:** [March 3, 2003, 4:58pm UTC](https://forum.kirupa.com/t/making-a-sound-loop/14562/20 "2003-03-03T16:58:34Z")

</div>

sorry … i should have told you before

place it in the timeline 🙂

[Next page](https://forum.kirupa.com/t/making-a-sound-loop/14562.md?page=2)
