embersyc
10-10-2009, 08:05 PM
Here is my class, but when I rollover the button, especially near the edge of the button the sound plays continuously. I have tried to set up a boolean variable and set it true after the sound plays and false on mouse out and only play when false, but that didn't work either... I was thinking about setting up a timer to handle it, but I wanted to make sure there wasn't something simpler I was missing first.
package {
import flash.display.MovieClip;
import flash.events.*;
public class BlankButton extends MovieClip {
private var clickSound:Click_Sound = new Click_Sound();
private var blipSound:Blip_Sound = new Blip_Sound();
public function BlankButton(txt:String, xLoc:Number, yLoc:Number) {
this.x = xLoc;
this.y = yLoc;
this.btn_txt.text = txt;
this.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_OVER, mover);
this.addEventListener(MouseEvent.MOUSE_OUT, mout);
this.addEventListener(MouseEvent.MOUSE_DOWN, mdown);
}
private function mover(e:MouseEvent):void
{
this.gotoAndStop(2);
blipSound.play();
}
private function mout(e:MouseEvent):void
{
this.gotoAndStop(1);
}
private function mdown(e:MouseEvent):void
{
this.gotoAndStop(3);
clickSound.play();
}
}
}
package {
import flash.display.MovieClip;
import flash.events.*;
public class BlankButton extends MovieClip {
private var clickSound:Click_Sound = new Click_Sound();
private var blipSound:Blip_Sound = new Blip_Sound();
public function BlankButton(txt:String, xLoc:Number, yLoc:Number) {
this.x = xLoc;
this.y = yLoc;
this.btn_txt.text = txt;
this.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_OVER, mover);
this.addEventListener(MouseEvent.MOUSE_OUT, mout);
this.addEventListener(MouseEvent.MOUSE_DOWN, mdown);
}
private function mover(e:MouseEvent):void
{
this.gotoAndStop(2);
blipSound.play();
}
private function mout(e:MouseEvent):void
{
this.gotoAndStop(1);
}
private function mdown(e:MouseEvent):void
{
this.gotoAndStop(3);
clickSound.play();
}
}
}