how can I add sound to a button on rollover?
I have tried this but the sound plays when the page is loaded aswell as when ouse over.
var aboutBtnsnd:Sound = new Sound(new URLRequest("clook.mp3"));
var aboutBtnchannel:SoundChannel = aboutBtnsnd.play();
var aboutBtnpausePosition:int = aboutBtnchannel.position;
Nav.aboutBtn.addEventListener(MouseEvent.MOUSE_OVER, aboutBtnstartSound);
function aboutBtnstartSound(event:MouseEvent):void {
if (aboutBtnchannel == null)
{
aboutBtnchannel = aboutBtnsnd.play(aboutBtnpausePosition);
}
}
Nav.aboutBtn.addEventListener(MouseEvent.MOUSE_OUT, aboutBtnstopSound);
function aboutBtnstopSound(event:MouseEvent):void {
aboutBtnchannel.stop();
aboutBtnchannel = null;
}