Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE FLASH: Adobe Flash ForumAdobe Flash TutorialsAdobe Flash Video TutorialsWeb Streaming ForumAdobe Flash

Sound ON / OFF button

Cow Forums : Adobe Flash
Sound ON / OFF button
by shavonne wijesinghe on Aug 29, 2008 at 3:08:52 pm

Hello

I found this tutorial where they teach you to add a sound on of button..

http://www.partnersinrhyme.com/contact/tutorials.php?sno=nil&nav=prev&pos=1...

But as you can see there is no ON or OFF buttong here.. I tried adding the symbols On and Off seperatly. But with the action script i got a bit mixed up and bith the labels are visibile at the same time..

------------------------- my code --------------
sound_btn_on._alpha = 0;
var mySound:Sound = new Sound();
mySound.attachSound("myTrack");
mySound.start();
var soundStarted:Boolean = true;
sound_btn_off.onRelease = function() {
soundStarted = !soundStarted;
if (soundStarted) {
this._alpha = 100;
mySound.start();
} else {
this._alpha = 0;
mySound.stop();
sound_btn_on._alpha = 100;
}
};

sound_btn_on.onRelease = function() {
soundStarted = !soundStarted;
if (soundStarted) {
this._alpha = 0;
mySound.start();
sound_btn_off._alpha = 100;
} else {
this._alpha = 0;
mySound.stop();
}
};

Respond to this post   •   Return to posts index

Re: Sound ON / OFF button
by Richard Williams on Aug 30, 2008 at 8:22:13 pm

here is a nice little bit of code i use.

In your main page inset a new layer, and create a button on this layer. In the first frame of this new layer, also insert the action script

soun = new Sound();

Now, click on the created button and in its action script type:

on (release) {
if (_root.sto == 1) {
Soun.setVolume(100);
_root.sto = 0;
{
gotoAndStop(1);
}
} else {
Soun.setVolume(0);
_root.sto = 1;
{
gotoAndStop(5);
}
}
}
This will switch the volune off and on, but will not stop the sound and replay it, so it will allow sound effects to not be affected.

There is more you can do here, attaching images to change also, i can send you these on file if you like, but try this first to see if its ok.

regards

Richard





Respond to this post   •   Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINEDVDsBOOKSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]