Link to home
Create AccountLog in
Avatar of cubical38
cubical38

asked on

AS3: I am unable to stop a sound using "stop"...

I am trying to stop a sound on MOUSE_UP.  This works fine if I use:  SoundMixer.stopAll();...  This is not going to work as I have a looping song in the background that will continue until otherwise stated.  Code is below:

if I replace:  SoundMixer.stopAll();  with Chisel_Sound_active.stop();  I receive this lovely error:

1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouse_down);
stage.addEventListener(MouseEvent.MOUSE_UP, mouse_up);
 
var req:URLRequest = new URLRequest("Chisel.mp3");
var Chisel_Sound_active:Sound = new Sound(req);
var sound:URLRequest = new URLRequest("ChiselWindDown.mp3");
var Chisel_WindDown:Sound = new Sound(sound);
 
function mouse_down(e:MouseEvent) {
	if (mouseX < 800 && mouseY < 570) {
		timer.start();
		timer2.start();
		Chisel_Sound_active.play();
	}
}
 
/*------function just like above, just for the mouse up event-------*/
function mouse_up(e:MouseEvent) {
 
	timer.stop();
	timer2.stop();
	SoundMixer.stopAll();
	Chisel_WindDown.play();
}

Open in new window

Avatar of Antonio Estrada
Antonio Estrada
Flag of Mexico image

Try Chisel_Sound_active.close(); instead

-V
ASKER CERTIFIED SOLUTION
Avatar of Eaddy Barnes
Eaddy Barnes
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of cubical38
cubical38

ASKER

That worked Thanks again...