Simple Mute and Unmute SWF with External FLV using Actionscript 3.0 AS3
snipped by k00k
I had such a hard time finding out how to do this simple task that I figured others have had the same difficulty. Here's some simple AS3 code that performs a mute and unmute of an external FLV.
I have a FLV file that is progressively streaming to my SWF from an httpd server. The instance name of that FLV is myPlayer. You can see that I simply set that instance's volume property to 0 or 1 (0% or 100% volume - mute or unmute). I originally was chasing soundMixer properties which were muting the "container" SWF, not the FLV. There might be a better way to do this but this seemed pretty small and lightweight for what I wanted.
import fl.video.VideoEvent; //import the video gunk // add a mouse click event listener to our mute_btn button symbol mute_btn.addEventListener(MouseEvent.MOUSE_DOWN, muteIt); // set up our mute/unmute function function muteIt(event:MouseEvent):void { // check to see if we're already muted or not // in this case, we're not muted if (myPlayer.volume == 1) { // so set the volume to 0 - muted myPlayer.volume = 0; } //otherwise we determine that we're muted //and thus we need to unmute (vol to 1 = 100%) else { myPlayer.volume = 1; } }




