Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to make a button in one frame mute all sound/audio in the next frame?

New Here ,
Mar 12, 2017 Mar 12, 2017

Hello,

I'm trying to create a toggle button that allows users to switch between having music playing or not playing by clicking on a button. However I cannot find a solution that works. Is there anyway for a button to mute all sound from playing in the next frame?

I currently have a start menu whereby music plays - below is the code for that section;

Frame 1 (Main Menu)

stop();

var s:Sound = new JazzyFrenchy_Bensound();

var sc:SoundChannel = s.play();

var s_bool:Boolean = true;

PlayBtn.addEventListener(MouseEvent.CLICK,PlayBtnFrame);

function PlayBtnFrame(e:MouseEvent):void

{

  gotoAndStop(2);

}

Frame 2 (Next Menu)

MusicToggle.addEventListener(MouseEvent.CLICK, OffBtnMusic);

function OffBtnMusic(e:MouseEvent):void

{

  if(s_bool){

  sc.stop();

  } else {

  sc=s.play();

  }

  s_bool=!s_bool;

}

OptionsBackButton.addEventListener(MouseEvent.CLICK, BacktoMenu);

function BacktoMenu(e:MouseEvent):void

{

  gotoAndStop(3)

  if(s_bool){

  sc.stop();

  } else {

  sc=s.play();

  }

  s_bool=!s_bool;

}

Any responses will be greatly appreciated.

Many thanks.

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

correct answers 1 Correct answer

LEGEND , Mar 12, 2017 Mar 12, 2017

You can import the SoundMixer with this:

import flash.media.SoundMixer;

then stop all sounds with:

SoundMixer.stopAll();

Translate
LEGEND ,
Mar 12, 2017 Mar 12, 2017

You can import the SoundMixer with this:

import flash.media.SoundMixer;

then stop all sounds with:

SoundMixer.stopAll();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2017 Mar 12, 2017

I have tried to include the SoundMixer.stopAll() but to no avail.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2017 Mar 12, 2017
LATEST

Your script for toggling the sound looks like it should work. Look in the Output panel in case there are errors happening that is stopping it from working correctly.

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