Mouse over sound

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.

Here you go:

_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. :slight_smile:

Tell me how it goes.

yours,
h88

thanx for replying soo fast, i wasnt expecting that! :slight_smile: 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…

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

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.

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

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… :slight_smile:
i appreciate u helping me out with this :slight_smile:

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

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

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

haha, r u serious?? sh*t :stuck_out_tongue:

Okay, done it for you:

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

np. :goatee:

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?

Hmm, yes, abit different, something like:

_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

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

sure. :bandit:

hey h88,
nice explanation for using deferent sounds … :slight_smile:

flasswimmer C:-)