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

Game ProgrammingAdobe Flash

Avatar of undefined
Last Comment
cubical38
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of cubical38
cubical38

ASKER

That worked Thanks again...
Adobe Flash
Adobe Flash

Adobe Flash (formerly Macromedia Flash) is a cross-platform multimedia and software platform used to embed animations, video, and interactive applications into web pages and desktop and mobile applications and games. Flash displays text, vector and raster graphics to provide animations, video games and applications. It allows streaming of audio and video, and can capture mouse, keyboard, microphone and camera input. The ActionScript programming language allows creation of interactive animations, video games, web applications, desktop applications and mobile applications.

29K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo