Groups | Blog | Home
all groups > flash (macromedia) > july 2004 >

flash (macromedia) : stop sounds w/ fadeout



randybruder
7/30/2004 8:39:52 PM
I have a very simple sound board in flash and some of the music clips are loops
of background music.
I was wondering, is there someway to have a "stop all sounds" button that,
instead of outright stopping the sounds like I have, fades the sounds out over
3 or 4 seconds? That would make my sound board alot smoother.

Thanks alot!

-Randy
urami_
7/31/2004 3:11:47 PM


[quoted text, click to view]

Sure Randy , pretty much possible ...

Place the sound in movie clip , select this movie clip and hit CTRL F3 to open the
Properties Panel , give the movie clip instance name . Call it MySoundMC

Than on main timeline frame place the following action :

mySound = new Sound(MySoundMC);
_root.onLoad = function() {
vol = 100;
step = 1;
};

Button or frame that will fade it at time you like would use the following action:

on (release) {
_root.onEnterFrame = function() {
trace(vol);
vol = vol-step;
if (vol<0) {
vol = 0;
delete this.onEnterFrame;
}
mySound.setVolume(vol);
};
}

--


Regards


urami_*

<hol>
http://flashfugitive.com/
</hol>


By The way:
If you try to mail me , DO NOT *laugh*
randybruder
8/2/2004 8:25:36 PM
i'm having a hard time getting that to work;

all of my sound files right now are on buttons that have the sound start on
the 'hit' frame. is there some way to generically fade out all sounds that are
playing? (like overall changing the volume?)

thanks!
randybruder
8/2/2004 8:31:38 PM
i tried doing something like this for a button, but the button does nothing.
whats wrong with this code:

on (release) {
i = 100;
s = new Sound();
while (i>0) {
s.setVolume(i);
i=i-Step
}
}
randybruder
8/2/2004 8:31:38 PM
i tried doing something like this for a button, but the button does nothing.
whats wrong with this code:

on (release) {
i = 100;
s = new Sound();
while (i>0) {
s.setVolume(i);
i=i-Step
}
}
Byron Canfield
8/11/2004 5:40:48 PM
You cannot use a for loop or a while loop to impart action (in the case,
volume changing), as nothing is updated until the loop as run. You must use
a frame loop, an onClipEvent(enterFrame), an onEnterFrame() function, or a
setInterval() function for that, the latter two of which can be launched
from within the button event script.

--
Byron Canfield
Headsprout, Inc.
--------------------------------------------------------
http://www.headsprout.com/help
"Where kids learn to read."
[quoted text, click to view]

AddThis Social Bookmark Button