Copy link to clipboard
Copied
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
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:
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
{
...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
So yeah is there a way to make scene 1 music play only on scene 1, scene 2 music play only on scene 2, etc automatically without having to click on a button that stops music?
Copy link to clipboard
Copied
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:
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
Copy link to clipboard
Copied
It worked!
Thank you so much, you saved my school project ❤️
Copy link to clipboard
Copied
Awesome! You're welcome!
Copy link to clipboard
Copied
hi I want to ask you, if I don't use the scene but I use the existing time line. How want to make many songs and he will stop where we want. I made an application that is divided into three parts of learning, quizzes and games
Copy link to clipboard
Copied
where are the sound files? already in animate or being loaded?
Copy link to clipboard
Copied
is in the adobe library already and i have placed it on the time line below
Copy link to clipboard
Copied
if you're going to use the timeline to start your sounds, the should stream and then place an empty keyframe where the sound should stop.
using code offers more control.