A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS3] turning off a sound in a mc from a button in the main timeline

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    22

    [CS3] turning off a sound in a mc from a button in the main timeline

    Hi. I have a movie clip that has a looping background sound in it. From a button on the main timeline, I want to stop that bgsound from playing. Is this possible?

    Here is my code on the movie clip:
    PHP Code:
    bgSound = new Sound();
    bgSound.attachSound("bgmusic");
    bgSound.start(0,20); 

    and in the button I have:
    PHP Code:
    on (release) {
    stopAllSounds();
    gotoAndStop(32);

    I don't want to use the stopAllSounds command because then it kills my sound on the button when clicked.

    Thanks for any help you can give.

  2. #2
    Hi,

    you just have to use Sound() function.

    Use script like this:

    Actionscript Code:
    globalvolume = new Sound();
    _root.globalvolume.setVolume(0);

    Aplly this to the onRelease funciton for the button. And set some variable to false for mute and true for sound.

    For Example in frame 1 write this script:

    _global.snd = true;
    globalvolume = new Sound();

    Then use this script for the button:

    Actionscript Code:
    on(release){

    if(_global.snd == true){

    _root.globalvolume.setVolume(0);

    _global.snd = false;

    }

    else {

    _root.globalvolume.setVolume(100);

    _global.snd = true;

    }

    }

    Good Luck


    Scotty does know how to Fla-make cool ads.

    http://flamake.net - this Ads will Fla-make you crazy. Find your cheap flash banners and see the best commercials around the world.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center