Can someone please help me out with this… Why won’t my sound play? It should play on MousOver and stop on MouseOut… Thank you ahead of time!
stop();
import flash.display.MovieClip;
import flash.events.MouseEvent;
var req:URLRequest = new URLRequest(“squeeak.wav”);
var sound:Sound = new Sound();
var controller:SoundChannel;
function soundLoaded(event:Event):void
{
controller = sound.play();
controller.stop();
this.addEventListener(MouseEvent.ROLL_OVER, playSound);
this.addEventListener(MouseEvent.ROLL_OUT, stopSound);
this.addEventListener(MouseEvent.CLICK, onClickHandler);
this.addEventListener(MouseEvent.MOUSE_DOWN, onPressHandler);
this.addEventListener(MouseEvent.MOUSE_UP, onReleaseHandler);
}
// if you want a hand cursor
this.buttonMode = true;
this.useHandCursor = true;
function playSound(myEvent:MouseEvent) {
trace(“On”);
this.gotoAndPlay(“one”);
controller = sound.play();
}
function stopSound(myEvent:MouseEvent) {
trace(“Out”);
this.gotoAndPlay(“two”);
controller.stop();
}
function onClickHandler(myEvent:MouseEvent) {
trace(“I waited for Press AND Release!!!”);
this.gotoAndPlay(“three”);
}
function onPressHandler(myEvent:MouseEvent) {
trace(“Press”);
}
function onReleaseHandler(myEvent:MouseEvent) {
trace(“Release”);
this.gotoAndPlay(“four”);
}
sound.addEventListener(Event.COMPLETE, soundLoaded);
sound.load(req);