Skip to main content
Participant
Apr 28, 2022 10:02 PM UTC
Answered

Background music doesn't stop in scene 2

I'm having a problem with the audio on Adobe Animate, I have a project with multiple scenes, I want to add background music to each scene but the problem is the music from scene 1 doesn't stop when I go to scene 2 & 3, or even when I go back to scene 1, they all get mixed together.
So how do I make the music play just for a specific scene and stops for another music to play in another scene?
Thanks

This topic is closed to new replies. Start a new post to keep the conversation going.
JoãoCésar17023019
JoãoCésar17023019Correct answer
Community Expert
Apr 29, 2022 11:25 AM UTC

Please make sure that the sound sync property is set to Event and that you are calling SoundMixer.stopAll(); before moving to another scene.

 

Here is an example:

https://bit.ly/3rZKAj9

 

AS3 code:

Scene 1

import flash.events.MouseEvent;
import flash.media.SoundMixer;

function gotoScene1(e:MouseEvent):void
{
	SoundMixer.stopAll();
	gotoAndStop(1, "Scene 1");
}

function gotoScene2(e:MouseEvent):void
{
	SoundMixer.stopAll();
	gotoAndStop(1, "Scene 2");
}

function gotoScene3(e:MouseEvent):void
{
	SoundMixer.stopAll();
	gotoAndStop(1, "Scene 3");
}

stop();
scene1Button.mouseEnabled = false;
scene2Button.addEventListener(MouseEvent.CLICK, gotoScene2);
scene3Button.addEventListener(MouseEvent.CLICK, gotoScene3);

 

Scene 2

import flash.events.MouseEvent;

scene1Button.addEventListener(MouseEvent.CLICK, gotoScene1);
scene2Button.mouseEnabled = false;
scene3Button.addEventListener(MouseEvent.CLICK, gotoScene3);

 

Scene 3

import flash.events.MouseEvent;

scene1Button.addEventListener(MouseEvent.CLICK, gotoScene1);
scene2Button.addEventListener(MouseEvent.CLICK, gotoScene2);
scene3Button.mouseEnabled = false;

 

I hope it helps.

 

Regards,

JC

10 replies

JoãoCésar17023019
Community Expert
Community Expert
Apr 29, 2022 9:34 AM UTC

Hi.

 

If you only have just one sound playing in each scene, an easy workaround is to run SoundMixer.stopAll(); before entering a new scene.

 

Please let us know if this works for you.

 

Regards,

JC

Translate
Participant
Apr 29, 2022 10:43 AM UTC

Thanks for replying 

This solution stops all music in every single scene, including the first scene when I go back to it, so when I jump to scene 2 or back to scene 1 there's no music anymore.

I'm trying to make a game for children and each scene is a level so I want to give each level a different background music.

Translate