Hello,
i’m trying to get a sound clip to play when rolling over the buttons. I was trying to integrate the following function to my actionscript file, but it ain’t working. i have tried many variations but no luck, any ideas?
thanks
Function:
this.addEventListener(MouseEvent.MOUSE_OVER, playSound);
function playSound(event:MouseEvent):void {
mySoundChannel = mySound.play();
}
var mySoundReq:URLRequest = new URLRequest(“songsample.mp3”);
var mySound:Sound = new Sound();
var mySoundChannel:SoundChannel = new SoundChannel();
mySound.load(mySoundReq);
Actionscript file code:
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class sieges extends flash.display.MovieClip{
var debug:Boolean=true;
public const SIEGE_LIBRE:int = 0;
public const SIEGE_SYSTEME:int = 1;
public const SIEGE_USER:int = 2;
var status:int = SIEGE_LIBRE;
// constructeur
public function sieges () {
if (debug) trace("siege:"+this.name);
this.addEventListener(MouseEvent.CLICK, siege_click);
this.addEventListener(MouseEvent.MOUSE_OVER, siege_over);
this.addEventListener(MouseEvent.MOUSE_OUT, siege_out);
siege_init();
}
// click sur un siege
function siege_click(event:MouseEvent):void {
if (debug) trace("siege_click");
if (this.status == SIEGE_LIBRE) {
user_reservation();
} else if (this.status == SIEGE_USER) {
siege_init();
this.parent.parent["durocher"].enleve_siege(this.name);
}
}
// over un siege
function siege_over(event:MouseEvent):void {
if (debug) trace("siege_over");
var request:URLRequest = new URLRequest("/reservations/images/"+this.name+".jpg");
this.parent["photo"].scaleContent = true;
this.parent["photo"].addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
this.parent["photo"].load(request);
event.target.alpha = .5;
}
function siege_out(event:MouseEvent):void {
if (debug) trace("siege_over");
event.target.alpha = 1;
}
function ioErrorHandler(e:Event):void {
}
public function siege_init() {
if (debug) trace("siege_init");
this.status = SIEGE_LIBRE;
gotoAndStop(1);
}
// reservation pour un usager
public function user_reservation () {
if (debug) trace("user_reservation");
this.status = SIEGE_USER;
this.parent.parent["durocher"].reserve_siege(this.name);
gotoAndPlay(10);
}
// reservation pour le systeme
public function system_reservation () {
if (debug) trace("syste,_reservation");
this.status = SIEGE_SYSTEME;
gotoAndPlay(5);
}
}
}
Actionscript file code