troubleshooting Question

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

Avatar of cubical38
cubical38 asked on
Game ProgrammingAdobe Flash
3 Comments1 Solution1411 ViewsLast Modified:
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();
}
ASKER CERTIFIED SOLUTION
Eaddy Barnes
IT

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros