Skip navigation
blairbooth1992
Currently Being Moderated

Controling an external swf with play and stop button functionality

Nov 27, 2012 10:56 AM

Tags: #cs5 #flash #as3 #swf #external

I'm using flash as3 cs5.  All I want to do is: import an external swf into a new fla and add a button for play and stop functionality.  The swf is just a graphic eq with music for background and I wish the user to be able to stop the swf sound and graphics.  The button play_Btn stops all sound and graphics but won't restart.

 

Here's my script thus far:

 

var Xpos:Number = 1;

var Ypos:Number = -20;

var swf:MovieClip;

var loader:Loader = new Loader();

 

 

var defaultSWF:URLRequest = new URLRequest("swfs/eq.swf");

 

 

loader.load(defaultSWF);

loader.x = Xpos;

loader.y = Ypos;

addChild(loader);

////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////

 

 

// Btns Universal function

function btnClick(event:MouseEvent):void {

 

          removeChild(loader);

          var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");

          loader.load(newSWFRequest);

          loader.x = Xpos;

    loader.y = Ypos;

          addChild(loader);

}

// Btn listeners

play_Btn.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds);

 

 

function fl_ClickToStopAllSounds(event:MouseEvent):void

{

          SoundMixer.stopAll();

}

 
Replies
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 27, 2012 11:16 AM   in reply to blairbooth1992

    what is it that you need to stop in your loaded swf?  the main timeline playing?  some movieclip playing?  do you need to call a function in the loaded swf? something else?

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 28, 2012 12:13 PM   in reply to blairbooth1992

    apply unloadAndStop() to your loader:

     

    loader.unloadAndStop();

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 29, 2012 7:10 AM   in reply to blairbooth1992

    what, in the loaded swf, is supposed to start?  i know you want sound and animation to start but that is not enough information.  you need (and anyone trying to help you needs) to know what causes the animation and sound to start.

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 29, 2012 9:24 AM   in reply to blairbooth1992

    if you can edit that code, change it to:

     

     

     

    package {

        import flash.media.*;

        import flash.net.*;

        import flash.display.*;

        import flash.events.*;

     

        import com.everydayflash.equalizer.*;

        import com.everydayflash.equalizer.color.*;

     

        public class Main extends Sprite{

     

    public var s:Sound;

    public var e:Equalizer;

    public var sc:SoundChannel;


            public function Main() {

               s = new Sound(new URLRequest("track.mp3"));

                sc = s.play(0, 100, new SoundTransform(1, 0));

     

                var es:EqualizerSettings = new EqualizerSettings();

                es.numOfBars = 32;

                es.height = 64;

                es.barSize = 4;

                es.vgrid = true;

                es.hgrid = 2;

                es.colorManager = new SolidBarColor(0xffff4444);

                es.effect = EqualizerSettings.FX_REFLECTION;

     

                e = new Equalizer();

                e.update(es);

                e.x = 0;

                e.y = -20;

                addChild(e);

     

                addEventListener(Event.ENTER_FRAME, e.render);

     

     

            }

        }

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points