PDA

View Full Version : Changing Scenes / Stop Sound Help?


gav.cooper
08-29-2007, 09:13 PM
Hi,

Firstly it’s safe to say that I’m still a n00b to actionscript, so I think I’m posting in the right section…

I’ve been working on a game over the summer and I need some help with controlling the music that a friend has made for it.

Level 1 is one scene and the user can either complete the stage or the user dies trying, either way the game changes scenes to the next level scene or the game over scene.

The problem I have is that even though the scene changes fom one to another the music from that 1st scene carries on playing… I need it to stop when the game changes scenes.

Does this make sense?

Basically, is there an actionscript command that stops the audio playing in a scene when leaving that said scene?

Cheers… :eek:

P.S
I'm using Flash MX 2004

CyanBlue
08-29-2007, 09:16 PM
Howdy and Welcome... :)

The solution varies depending on how you are playing the music, but you could try adding stopAllSounds() function call when you want the music to stop and see if it works...

gav.cooper
08-29-2007, 09:20 PM
I have just added the music as a .WAV file onto the timeline, with its own layer, so as the game plays out so does the music.

I'd have thought when the scenes change the music would cease, as do the visuals for that particular scene, but no :-(

does that help?

CyanBlue
08-29-2007, 09:40 PM
Your thought is the same as mine and I have no idea why it won't stop playing... Hm...

atomic
08-29-2007, 09:43 PM
stopAllSounds();

On the first frame of the next scene, should stop all playing sounds.

CyanBlue
08-29-2007, 09:49 PM
Do I hear an echo??? :p

Just kidding... That's what he tried and he still says he hears the sound... Any idea what might be happening???

gav.cooper
08-29-2007, 09:50 PM
thanks! I'll give the "stopAllSounds();" on the next scene a try...

but... what if the next scene has its own seperate music aswell?
will the "stopAllSounds();" command stop that lot of music playing aswell?

atomic
08-29-2007, 09:52 PM
No where did he specifically say that he had added stopAllSounds(); on the timeline... He only expected the sound to stop when the scene changed!

atomic
08-29-2007, 09:54 PM
stopAllSounds(); only stops currently playing sounds...
So if you add it to the first frame of the scene, it should stop the currently playing sound, but if you start a new sound on frame 2, that one should be heard.

@ CyanBlue :p

CyanBlue
08-29-2007, 10:00 PM
Maybe I am just getting older... :(

atomic
08-29-2007, 10:04 PM
And blinder! :o

gav.cooper
08-29-2007, 11:44 PM
thanks... I'll give it a whirl...

atomic
08-30-2007, 01:28 AM
;)