1 Reply Latest reply on Apr 7, 2008 4:52 PM by Gregory Lafrance

    Turn Off Sound Effect?

    Cpt._Awesome
      Can anybody give me the code for turning off a sound effect with a button? Thanks.
        • 1. Re: Turn Off Sound Effect?
          Gregory Lafrance Level 6
          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
          <mx:Script>
          <![CDATA[
          import flash.media.*;

          [Embed(source="locale/en_us/LaMarseillaise.mp3")]
          [Bindable]
          public var sndCls:Class;
          public var snd:Sound = new sndCls() as Sound;
          public var sndChannel:SoundChannel;

          public function playSound():void {
          sndChannel=snd.play();
          }

          public function stopSound():void {
          sndChannel.stop();
          }
          ]]>
          </mx:Script>
          <mx:HBox>
          <mx:Button label="play" click="playSound();"/>
          <mx:Button label="stop" click="stopSound();"/>
          </mx:HBox>
          </mx:Application>