# Mouse over sound

**URL:** <https://forum.kirupa.com/t/mouse-over-sound/8656>\
**Category:** Uncategorized\
**Created:** [November 26, 2002, 1:29am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656 "2002-11-26T01:29:05Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk8erboi\_Q8](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@sk8erboi\_Q8](https://forum.kirupa.com/u/sk8erboi_Q8)\
**Post date:** [November 26, 2002, 1:29am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/1 "2002-11-26T01:29:05Z")

</div>

i have a button, and when the mouse is over it a sound is played, how can i make it that when the mouse is not over the button the sound is stopped? please help!! thnx.

---

<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:** [November 26, 2002, 1:50am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/2 "2002-11-26T01:50:25Z")

</div>

Here you go:

```php
_root.createEmptyMovieClip("mySound_mc", 10);
mySound = new Sound(mySound_mc);
mySound.loadSound("soundFile.mp3");
myButton.onRollOver = function() {
	mySound.start();
};
myButton.onRollOut = function() {
	mySound.stop();
};

```

Well, define your button instance name, and replace your sound file in the script.

**NOTE** : This will load your Sound File Dynamically, no need for importing it into Flash. 🙂

Tell me how it goes.

yours,  
h88

---

<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:** [November 26, 2002, 2:00am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/3 "2002-11-26T02:00:05Z")

</div>

thanx for replying soo fast, i wasnt expecting that! 🙂 i named my instance as u said and replaced it with u’r “mySound\_mc”…but what i dont get is how i dont have to import the sound… does the sound have to be in the same folder as the .fla file and do i just name the file? thnx…

---

<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:** [November 26, 2002, 2:06am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/4 "2002-11-26T02:06:43Z")

</div>

Nope, you got me wrong , if your button, for ie, was called “Button48”, replace myButton with Button48, don’t name your instance mySound\_mc, cuz i already created an MC where the sound will load. In line no.3, replace soundFile.mp3 with your own file, don’t delete the quotes, and keep this sound file in the same directory of your SWF.

Tell me how it goes.

oh and btw, u should paste this script in your \_root (main) timeline.

yours,  
h88

---

<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:** [November 26, 2002, 2:32am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/5 "2002-11-26T02:32:04Z")

</div>

when i publish or test movie, a pop up comes up and says:

WARNING: This movie uses features that are not supported in the Flash 5 player  
Scene=site, Layer=Layer 1, Frame=1: Flash MX Button Instance Name

i am using FLASH MX, is there a problem with the actionscripting, is it not compatible with flash mx or something…  
thnx.

---

<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:** [November 26, 2002, 2:34am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/6 "2002-11-26T02:34:00Z")

</div>

Well, it worked here, i think you was testing it in flash 5 workspace! what about zipping all your directory and attaching it here?

---

<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:** [November 26, 2002, 2:36am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/7 "2002-11-26T02:36:56Z")

</div>

that cant be!  
i am using flash mx! here are my details… my button instance name is = me  
the folder where the .swf and .mp3 files are is called BATAT

u need nething else, just lemme know… 🙂  
i appreciate u helping me out with this 🙂

---

<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:** [November 26, 2002, 2:38am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/8 "2002-11-26T02:38:39Z")

</div>

Well, can u zip up all your directory and attach it here:q:

---

<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:** [November 26, 2002, 2:43am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/9 "2002-11-26T02:43:28Z")

</div>

ok, i zipped the whole folder, i removed all the actionscripting i made and the buttons instance name…coz its all a mess! :-\  
heres the .zip

---

<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:** [November 26, 2002, 2:47am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/10 "2002-11-26T02:47:35Z")

</div>

Thats really weired, i got the message you were talking about as well. :-\

---

<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:** [November 26, 2002, 2:49am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/11 "2002-11-26T02:49:02Z")

</div>

haha, r u serious?? sh\*t 😛

---

<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:** [November 26, 2002, 2:57am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/12 "2002-11-26T02:57:25Z")

</div>

Okay, done it for you:

---

<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:** [November 26, 2002, 3:01am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/13 "2002-11-26T03:01:09Z")

</div>

IT WORKS!! THANX ALOT 🙂 thnx a millioN!!! u’r a genius!! hehe

---

<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:** [November 26, 2002, 3:02am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/14 "2002-11-26T03:02:16Z")

</div>

np. :goatee:

---

<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:** [November 26, 2002, 3:07am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/15 "2002-11-26T03:07:44Z")

</div>

hehe, one more question, sorry! u know my other buttons…like contact…if i wanted another sound to be played on that button, is that possible?

---

<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:** [November 26, 2002, 3:13am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/16 "2002-11-26T03:13:27Z")

</div>

Hmm, yes, abit different, something like:

```php
_root.createEmptyMovieClip("mySound_mc", 10);
mySound = new Sound(mySound_mc);
mySound.loadSound("me.mp3");
mySound1 = new Sound(mySound_mc);
mySound1.loadSound("232.mp3");
myButton.onRollOver = function() {
    mySound.start();
};
myButton.onRollOut = function() {
    mySound.stop();
};
myButton1.onRollOver = function() {
    mySound1.start();
};
myButton1.onRollOut = function() {
    mySound1.stop();
};

```

etc…just start adding what i added for each sound, tell me how it goes.

yours,  
h88

---

<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:** [November 26, 2002, 3:18am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/17 "2002-11-26T03:18:50Z")

</div>

IT WORKS!! THANX AGAIN!!! I’M GETTING TO START TO LIKE U , LOL 😛  
thnx man…

---

<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:** [November 26, 2002, 3:19am UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/18 "2002-11-26T03:19:57Z")

</div>

sure. :bandit:

---

<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:** [November 26, 2002, 7:11pm UTC](https://forum.kirupa.com/t/mouse-over-sound/8656/19 "2002-11-26T19:11:18Z")

</div>

hey h88,  
nice explanation for using deferent sounds … 🙂

_flasswimmer_ C:-)
