1 Reply Latest reply on Jul 19, 2011 11:32 PM by relaxatraja

    Muting audio on multiple embedded MCs

    joshuantaylor Level 1

      I have a file with one main mc called "clip" that contains 9 different embedded audio tracks (all inside their own separate mc) on the first keyframe. They span the entire length of the mc - 10 frames in this case.

       

      Essentially what this does is creates a full song with 9 separate tracks that I want to mute (and unmute) when I arrive at a specific keyframe.

       

      I am using a slider (called "aSlider") on the main timeline to navigate between the keyframes.

       

      Everything starts out muted and as we progress, tracks are unmuted and the song starts to build. It is working great right now in that direction. However, if I move the slider backwards, it seems to be re-creating the audio clips so that I am overlaying more and more audio on top of each other.. which is quite the mess.

       

      Here's the AS for the slider.

       

      aSlider.width = 324;

      aSlider.move(309, 681); 

       

      addChild(aSlider); 

       

      trace(mc.totalFrames);

       

      aSlider.maximum = mc.totalFrames;

      aSlider.liveDragging=true;

      aSlider.addEventListener(Event.CHANGE,mcHandler);

       

       

      function mcHandler(e:Event){

          mc.frameTxt.text = aSlider.value;

      trace("aSlider.value: "+aSlider.value);

      mc.gotoAndStop(aSlider.value);

      }

      And here's the AS for each individual frame inside the main mc.
      stop();
      piano.volume=.5;
      trackPiano.soundTransform=piano;
      violin.volume=.5;
      trackViolin.soundTransform=violin;
      cello.volume=.5;
      trackCello.soundTransform=cello;
      drums.volume=0;
      trackDrums.soundTransform=drums;
      bass.volume=0;
      trackBass.soundTransform=bass;
      electro.volume=0;
      trackElectro.soundTransform=electro;
      voice.volume=0;
      trackVoice.soundTransform=voice;
      synth.volume=0;
      trackSynth.soundTransform=synth;
      guitarra.volume=0;
      trackGuitarra.soundTransform=guitarra;
      ANY help on how I can keep the tracks from duplicating on top of themselves would be GREATLY appreciated. Thanks so much!

        • 1. Re: Muting audio on multiple embedded MCs
          relaxatraja Level 5

          I did not tested the below code, but give it a try

           

          stop();
          //on First Frame
          var arr:Array=new Array(piano,violin,cello,drums,bass,electro,voice,synth,guitarra);
          function controlSound(str:String,vol:Number):void(
            for(var i=0;i<arr.length;i++){
                this[arr[i]].volume=0;
                this["track"+arr[i]].soundTransform=this[arr[i]];
            }
            this[str].volume=vol;
            this["track"+str].soundTransform=this[str];
          }

          //other frames just call the function like
          controlSound(arr[0],.5);