Skip to main content
Participant
April 28, 2022
Answered

Background music doesn't stop in scene 2

  • April 28, 2022
  • 1 reply
  • 1701 views

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 has been closed for replies.
Correct answer JoãoCésar17023019

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

1 reply

JoãoCésar17023019
Community Expert
Community Expert
April 29, 2022

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

Participant
April 29, 2022

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.