From: David Stiller on
Lucky Kitty,

> I tried this code for a toggle mute/unmute button, but get an error.
> What do you suggest?

What error are you getting?

> on (release)
> if(mute=false{

The condition being tested in an if() statment must fall within the if()
statement's parentheses. There should be a right parenthesis after the word
false, there.

In addition, you're using the assignment operator (=), rather than the
comparison operator (==). When you're *checking* to see if one thing equals
another, use the double equals.

> stopAllSounds();
> mute=true;
> }

Here, you're calling the stopAllSounds() global function and setting the
mute variable to true. Nothing wrong there.

> else {

Okay, originally, you were checking if mute was equal to false. If it
wasn't -- meaning, mute is true -- you're doing the following ...

> startAllSounds ();

What's this? There is no startAllSounds() function in the ActionScript
Language Reference. Is this a function you wrote?

> mute=false;
> }
> }

Here, you're setting mute to false.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."


From: ImagicDigital on
Firstly, read your error messages that pop up in the Output window. You are
missing an opening bracket for your function, and a closing bracket on your if
parameter.

That fixed, the function you wrote won't turn your sound back on, because
there is no such command as startAllSounds.

Check into the replies from David, or do the easy google search for: "toggle
sound" group:*flash* . Here's a great example, posted on this forum by
NSurveyor:

Open up the library. Right click on your sound. Select Linkage... Check off
the box 'Export for ActionScript'. Type in mySong for the linkage identifier.
Hit OK. Then, on Frame 1 of your movie, add:

mySound = new Sound();
mySound.attachSound("mySong");
mySound.start();

if you want to have one toggle button, you can give your button the <Instance
Name> toggle_btn and add this code to the above:

toggle_btn.onPress = function(){
stopped = !stopped;
if(stopped){
mySound.stop();
}else{
mySound.start(0);
}
}

From: uomoDiCuore on
In your posted code, you don't have curly bracket after on(release)
From: Lucky Kitty on
I tried the following code, and it does stop the music. The promblem I'm
having is that the music begins in the first frame of scene one and is synch to
event, because i want this background music to play through all scenes. So
when I re-click the button to "un mute" the sound, it doesn't start again.
Help :-)

on (release) {
// Toggle a flag between TRUE and FALSE:
IamActive = not IamActive;


if (IamActive) {
// Mute sounds for "on" state of button
stopAllSounds();
} else {
// Override Mute for "off" state of button
myCurrentFrame = _currentframe
gotoAndPlay(myCurrentFrame);
}



}


From: Lucky Kitty on
Found this on google.. and it works. :-)

--------------------------------------------------------------------------------
---------

MadCat
Aug 31 2001, 1:09 pm show options

Newsgroups: macromedia.flash
From: "MadCat" <davidree...(a)hotmail.com> - Find messages by this author
Date: Fri, 31 Aug 2001 19:07:34 +0100
Local: Fri, Aug 31 2001 1:07 pm
Subject: Mute Sounds
Reply to Author | Forward | Print | Individual Message | Show original |
Report Abuse


Is there any way to mute the sounds rather than to stop all of the sounds, as
when I do stop the sounds, the sounds keep on coming back.?



urami_
Aug 31 2001, 9:39 pm show options

Newsgroups: macromedia.flash
From: urami_ <ura...(a)flashfugitive.com> - Find messages by this author
Date: Sat, 01 Sep 2001 10:39:25 +0800
Local: Fri, Aug 31 2001 9:39 pm
Subject: Re: Mute Sounds
Reply to Author | Forward | Print | Individual Message | Show original |
Report Abuse

Import sound to flash .
Open library CTRL L - right click on sound file in the library and go
to LINKAGE
Check EXPORT THIS SYMBOL box and give that sound some ID name ,
let's call it 'LOOP'.


Now you need to create sound object :
paste the following in timeline frame :


s = new Sound( );
s.attachSound("LOOP");
s.setVolume(100);
s.start( 0 , 999 );


NOTE !
0 is secondOffset and 999 is number of loops.


And if you want to mute the audio than use this button or frame action :
on (release) {
_root.s.setVolume(0);



}


or
on (release) {
_root.s.setVolume(100);


- Hide quoted text -
- Show quoted text -