Play MP3 on rollover

Greetings,

I’ve got a simple rotating banner and would like to have an mp3 play if someone rolls over the banner and stop if they move their mouse away.

I grabbed some code from this forum and placed it on my button instance but it’s not working.

Here are the working files:

http://www.4shared.com/file/szB6OiYc/gh_2.html

I’ve “linked” the mp3 file and given it the ID of “makin” and posted the following actionscript on the button instance:

Actionscript Code:


// button actions
on (rollOver){
// creates a new object from Sound class
yourSound = new Sound();
// attach the 'idSound' named from library
yourSound.attachSound("makin");
// start the sound attached
yourSound.start(0,1);
}
on (rollOut){
yourSound.stop();
}

Any help would be greatly appreciated.

Thanks

The code you used is in AS 2.0, not AS 3.0.
Are you sure that’s what you wanted?

Try adding a var to your declaration:


// button actions
on (rollOver){
   // creates a new object from Sound class
   var yourSound:Sound = new Sound();
   // attach the 'idSound' named from library
   yourSound.attachSound("makin");
   // start the sound attached
   yourSound.start(0,1);
}
on (rollOut){
   yourSound.stop();
}

‘var’ is not necessary
The sound must be in the library of the current movie and specified for export in the Symbol Linkage Properties dialog box