16 Replies Latest reply on Jan 13, 2011 5:57 PM by yalp.com.br

    Controling sound of an external SWF PLS HELP!!!!!

    yalp.com.br Level 1

      Hi All,


      I'm trynig to control an sound of a external SWF but I can't seem to get it right, I'm kind of new in AS and would really apreciate any given HELP!


      here is the code i'm using to import the sound


      mport flash.media.Sound;
      import flash.net.URLRequest;
      import flash.display.Sprite;
      import flash.media.SoundChannel;
      import flash.events.Event;
      import flash.events.MouseEvent;

      var _som1:Sound;
      var _channel1:SoundChannel;
      var _playing1:Boolean = false;
      var _position1:int;

      _som1 = new Sound( new URLRequest ( "som1.mp3"));
      _channel1 = _som1.play();

      //this controls the sound inside the SWF
      //this code has to be on the main SWF
      _play.addEventListener(MouseEvent.CLICK, playSound);
      _pause.addEventListener(MouseEvent.CLICK, pauseSound);

      function playSound(event:MouseEvent):void {
          _channel1 = _som1.play(_position1);

      function pauseSound(event:MouseEvent):void {
          _position1 = _channel1.position;


      My main SWF calls the internal one inside a movie clip, here is the code if it helps in any way...

      var loadAnimBox:Loader = new Loader();
      var vid_mc:MovieClip;

      function startLoading():void {
          loadAnimBox.contentLoaderInfo.addEventListener(Event.COMPLETE, onBoxLoaded);
          // load the box animation SWF
          loadAnimBox.load(new URLRequest((meuCaminho.parameters.var3) + ".swf"));

      function onBoxLoaded(e:Event):void {
          loadAnimBox.contentLoaderInfo.removeEventListener(Event.COMPLETE, onBoxLoaded);

          vid_mc = loadAnimBox.content as MovieClip;
          // We listen for that event:
          vid_mc.addEventListener("firstAnimationComplete", onFirstComplete, false, 0, true);   
          // set up the play button
          play_btn.addEventListener(MouseEvent.CLICK, playClick);   
          stop_btn.addEventListener(MouseEvent.CLICK, stopClick);


      function onFirstComplete(e:Event):void {
          // we should remove the listener if we're not going to play this again
          trace("First animationn complete, start second animation.");

      function playClick(e:MouseEvent):void {
      function stopClick(e:MouseEvent):void {



      Thanks for the attention....best regards!!!