Highlighted

Stop all sounds and transition to new scene with new audio?

New Here ,
Nov 18, 2019

Copy link to clipboard

Copied

I've been trying to get a main menu's audio to function properly, and it hasn't gone all too well. It links to two separate scenes, each with their own audio. To prevent it from layering the main menu music over each scene's music, I gave the buttons the preset "stop all sounds" ActionScript 3.0 command. Problem is, this snippet keeps the audio from behaving the way I want it to, which would be stopping the main menu track and immediately starting the audio in the new scene.

 

These separate scenes are a requirement, (this is a school project) and I have no other option. Audio aside, buttons function as they should. Each scene that the buttons link to possess two layers of sound that are intended to start immediately upon transition, a sound-effect (that was previously part of the button's down frame and worked until I had to figure out how to keep music from overlaying) and the music. I'd moved the button's sound to the first frame of the other scenes so that it would still seem as though it was part of the down frame, since the stop all sounds cancels out the button's attached sound effect.

 

I've seen a thread where someone else had a similar issue, but from the way they described it, their project was all one scene, and they weren't handling audio across scenes, so I doubt that the code recommended in their case would help me.

 

The code I have attached to frame 1 involving the buttons is as follows:

 

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_2);

function fl_ClickToGoToScene_2(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "movie 1");
}

button_2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_3);

function fl_ClickToGoToScene_3(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "movie 2");
}

 

button_2.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds);

function fl_ClickToStopAllSounds(event:MouseEvent):void
{
SoundMixer.stopAll();
}

 

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds_2);

function fl_ClickToStopAllSounds_2(event:MouseEvent):void
{
SoundMixer.stopAll();
}

 

EDIT: I did a dumb and forgot to convert the BGM in both scenes to stream.

TOPICS
ActionScript, Code

Views

48

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Stop all sounds and transition to new scene with new audio?

New Here ,
Nov 18, 2019

Copy link to clipboard

Copied

I've been trying to get a main menu's audio to function properly, and it hasn't gone all too well. It links to two separate scenes, each with their own audio. To prevent it from layering the main menu music over each scene's music, I gave the buttons the preset "stop all sounds" ActionScript 3.0 command. Problem is, this snippet keeps the audio from behaving the way I want it to, which would be stopping the main menu track and immediately starting the audio in the new scene.

 

These separate scenes are a requirement, (this is a school project) and I have no other option. Audio aside, buttons function as they should. Each scene that the buttons link to possess two layers of sound that are intended to start immediately upon transition, a sound-effect (that was previously part of the button's down frame and worked until I had to figure out how to keep music from overlaying) and the music. I'd moved the button's sound to the first frame of the other scenes so that it would still seem as though it was part of the down frame, since the stop all sounds cancels out the button's attached sound effect.

 

I've seen a thread where someone else had a similar issue, but from the way they described it, their project was all one scene, and they weren't handling audio across scenes, so I doubt that the code recommended in their case would help me.

 

The code I have attached to frame 1 involving the buttons is as follows:

 

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_2);

function fl_ClickToGoToScene_2(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "movie 1");
}

button_2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_3);

function fl_ClickToGoToScene_3(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "movie 2");
}

 

button_2.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds);

function fl_ClickToStopAllSounds(event:MouseEvent):void
{
SoundMixer.stopAll();
}

 

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds_2);

function fl_ClickToStopAllSounds_2(event:MouseEvent):void
{
SoundMixer.stopAll();
}

 

EDIT: I did a dumb and forgot to convert the BGM in both scenes to stream.

TOPICS
ActionScript, Code

Views

49

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 18, 2019 0

Have something to add?

Join the conversation