Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 703921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:53:03+00:00 2026-05-14T03:53:03+00:00

I thought I could change the Boolean true/false value, but it’s not working. How

  • 0

I thought I could change the Boolean true/false value, but it’s not working. How do I get this to hush, until the button is pressed?

import flash.media.Sound;
import flash.media.SoundChannel;

var soundOn:Boolean = true; //music is ON when we start
var myToons:TitleMusic = new TitleMusic();
var myChannel:SoundChannel = myToons.play(0,1000); // endless loop, in effect
var myTransform:SoundTransform;

mySoundButton.addEventListener(MouseEvent.CLICK,toggleSound);
mySoundButton.buttonMode = true;
mySoundButton.mouseChildren = false;


function toggleSound(e:MouseEvent)
{
    if(soundOn)
    {
        // turn sound off
        myTransform = new SoundTransform();
        myTransform.volume = 0; // silent
        myChannel.soundTransform = myTransform;
        soundOn = false;
        mySoundButton.myButtonText.text = "click to turn sound ON";
    }
    else // sound is off
    {
        // turn sound on
        myTransform = new SoundTransform();
        myTransform.volume = 1; // full volume
        myChannel.soundTransform = myTransform;
        soundOn = true;
        mySoundButton.myButtonText.text = "click to turn sound OFF";
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:53:04+00:00Added an answer on May 14, 2026 at 3:53 am

    Don’t need Boolean statements. Here’s what I did.

    The variable ‘mySound’ instantiates the sounds. I hand control of the sound to ‘myChannel’. Buttons from the components panel are given there names. Make sure to set up your mp3 properties correctly, Name ‘Sound, Class ‘Sound’. Everything should work!

    Play and Stop embedded mp3

                    /*      
                    place mp3 in library. 
                    Give it a Name and Class of 'Sound'
                    */
            var mySound:Sound = new Sound();
                    //control the channel that your sound is on
            var myChannel:SoundChannel = new SoundChannel();
    playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler);
                    /*
                    Grab a Play and Stop button from the components menu.
                    Go to Properties Panel and give each an instance name.
                    Play is 'playButton', Stop is 'stopButton'
                    */
            function myPlayButtonHandler (e:MouseEvent):void {
                    //mySound.play();//use channel instead 
                myChannel = mySound.play();
                }
                    //Stopping the sound channel
    stopButton.addEventListener(MouseEvent.CLICK, onClickStop);
            function onClickStop(e:MouseEvent):void{
                myChannel.stop();
                }
    

    Load external mp3 option

                //URL load and auto play of external file "myMp3.mp3"
                var mySound:Sound = new Sound();
                snd.load(new URLRequest("myMp3.mp3"));
                snd.play();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.