fading the volume of all non-looping event sounds in an mc or root?

Posted on 2003-03-20
Medium Priority
Last Modified: 2010-04-03
   hello ..i require some assistance : i have a looping animation assigned to each section of my site { a dog performing various tricks } ..with each animation come various miscellanious soundFX triggered on event ..what i would like to have happen after a certain time period { which can be specified by x number of frames if necessary } / once the animation has run through the loop two or three times ..i'd like all sounds relating to this animation / mc ONLY to fade out so as not to annoy the end user ..is this possible .[?]..

    i have tried to adapt a few 'fade out' tutorials but they only tend to effect looping sounds... .. .

    the solution to this question would be a very handy piece of script because it could be adapted to fade out all the root mc sounds too { presumeably } which is indeed handy 'cos that would mean that the end user can effectivly turn off { fade out } ALL sounds - rollover soundFX etc NOT just the background music... .. .

    please advise

    much appreciated

    tim ferguson
    the aural encosion theory
                ___  __  _
 .s%Ss. _..s$ý'
$ý' `ý"s
Question by:encosion
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1

Expert Comment

ID: 8176738
This is one way you can do it. One the MC Dog or whatever, make three keyframes. Whereever you press the button, add that to the MC. Add it so on the button it goes to the next frame. Then add a fourth one that goes back to the third. On the third one make the sound lower or whatnot. I think that solves your problem.
LVL 22

Expert Comment

ID: 8176795
you could make a movieclip that when initiated would have code in each frame that would steadily lower the volume of the specific movieclip sound...

something like this in every frame:


or you coule decrease the value by multibles of 2 or 5 or what ever...  for the above code, it would take 100 frames to fade all of the way out...

you could use just one clip for this and use variables to set the name of the audio clip that is playing and then same for the fade out...

this is just one sneaky way to do it...

you should adapt it into your own code, and try to explore the possibilities...



Expert Comment

ID: 8176994
if u are using mx, u can have the sound start, stop, fade ... anytime a particular frame, loop once, or twise then stop ... anything u want :)

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8179320
thank you for your comments however i don't think the question has been understood : in each looping mc where the dog performs a trick, there are several 'one shot' sounds triggered on event ..these sounds are very short and do not loop { for example when the dog drops the ball a bounce / boing sound is triggered } ..there are several short 'one shot' sounds triggered in each animation... .. .

my experience of the sound object setVolume() is that it only sets the volume of a specific sound that is already playing / looping ..NOT the global volume of the mc or root so that all new sounds triggered are affected by the volume change... .. .

any ideas .[?]..
LVL 22

Expert Comment

ID: 8181639
you can just put all of the sounds in a movieclip and use the setVolume() if that is what you need...

do you want to mute the entire movie or just a sound clip?

entire movie = stopAllSounds();
movieclip = setVolume();

what do you want to do?


Accepted Solution

henryww earned 300 total points
ID: 8181821
arr ... i am sure if i understand now ...
so the dog does the trick in a loop right ...
and it has some sounds attached to it ...

have a sound object to play the sound if it has been played a few times during the session then u want it to stop??

have a few sound objects and a variable to check if that sound has been played enough ..

like ... eg
// frame 1 main timeline
sndplayed = 0;
sndBg = new Sound Object();
sndFx = new Sound Object();

ok .. assume u have all the sounds exported (linked)

when the is playing the trick1 movieclip
in that movieclip

//frame 1 - have the 1st frame in each clip to init the sound object

//frame 2
_root.sndBg.onSoundComplete=function () {
   if (sndplayed < 4) {
   } else {
   //fade out
   this.onEnterFrame = function () {
     _root.sndBg.setVolume(_root.getVolume() - 2);
     if (_root.getVolume <= 0 ) {
        this.onEnterFrame = null;

//frame X with the ball drop again
if(_root.sndplayed < 4 )  { //plays 3 times

//frame X + N
gotoAndPlay(2); // <- don't play 1 again

repeat for each tricks ...

try and see if this help


Author Comment

ID: 8182149
thank you ..henryww : at a glance this looks like the solution ..thank you very much ..i'll put it together and play around until i get it working ..i'll be back to let you all know how it turned out and to 'award the points to the winner!' ..heheh ..thanks again... .. .

Author Comment

ID: 8193873
thank you very much ..however there is an unfortunate side effect to this solution : actionscript doesn't really allow you to set in, out and envelope points which is what i was using to recycle some of my sounds without sound the same ..so unfortunately i can't use this technique in my presentation.... .. . the soundoffet value is pretty useless too as it will only accept whole numbers which are far from precise ..does anyone ever even use this function .[?]..

Expert Comment

ID: 8194635
yeah, the offset only works for whole number (sec)
hmmm ... but i don't quite understand how u recycle the sound ...


Author Comment

ID: 8202146
what i mean is i can get more mileage out of an individual sound clip by using it several times with different in, out and envelope points for each instance ..for example the sound of a ball bouncing can be used twice for two different sound effects ..one without any adjustments to reprasent the sound effect of a ball bouncing ..and another instance can reprasent the sound of the ball when it stops ..or lands on something hard { by tweaking the in, out and envelope points }... .. .

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question