Skip navigation
Currently Being Moderated

Pause/Play for external SWF

Feb 5, 2013 10:29 AM

Can anyone help me witht this? I've been going crazy trying to figure it out because nothing is working out. I am trying to create a pause/play button that will pause and play everything on the main timeline (easy), as well as an external SWF that is being loaded with the Loader class. Here is my code:

 

var myLoader:Loader = new Loader();                 // create a new instance of the Loader class

var url:URLRequest = new URLRequest("MYCONTENT.swf");

myLoader.load(url);                                 // load the SWF file

myLoader.x = 134;

myLoader.y = 148;

addChild(myLoader);

 

On the main timeline I have a MovieClip that is the Pause/Play button. It toggles between the two. How do I get it to control the external SWF as well?

 

On Frame 1:

stop();

 

pauseBtn.addEventListener(MouseEvent.CLICK, pauseMovie);

 

function pauseMovie(e:Event): void {

    gotoAndStop(2);

     MovieClip(root).stop();

    MovieClip(root).myLoader.content.stop();  ///??????????

    }

 

On frame 2:

playBtn.addEventListener(MouseEvent.CLICK, playMovie);

function playMovie(e:Event): void {

    gotoAndStop(1);

     MovieClip(root).play();

    MovieClip(root).myLoader.content.play();  ///????????????

}

 
Replies
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Feb 5, 2013 12:16 PM   in reply to CEItim

    if myLoader is on the root timeline, use:

     

     

     

    var myLoader:Loader = new Loader();                 // create a new instance of the Loader class

    var url:URLRequest = new URLRequest("MYCONTENT.swf");

    myLoader.load(url);                                 // load the SWF file

    myLoader.x = 134;

    myLoader.y = 148;

    addChild(myLoader);

     

    On the main timeline I have a MovieClip that is the Pause/Play button. It toggles between the two. How do I get it to control the external SWF as well?

     

    On Frame 1:

    stop();

     

    pauseBtn.addEventListener(MouseEvent.CLICK, pauseMovie);

     

    function pauseMovie(e:Event): void {

        gotoAndStop(2);

         MovieClip(root).stop();

        MovieClip(root.myLoader.content).stop();  ///??????????

        }

     

    On frame 2:

    playBtn.addEventListener(MouseEvent.CLICK, playMovie);

    function playMovie(e:Event): void {

        gotoAndStop(1);

         MovieClip(root).play();

        MovieClip(root.myLoader.content).play();  ///????????????

    }

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Feb 5, 2013 1:14 PM   in reply to kglad

    try:

     

     

     

     

     

    var myLoader:Loader = new Loader();                 // create a new instance of the Loader class

    var url:URLRequest = new URLRequest("MYCONTENT.swf");

    myLoader.load(url);                                 // load the SWF file

    myLoader.x = 134;

    myLoader.y = 148;

    addChild(myLoader);

     

    On the main timeline I have a MovieClip that is the Pause/Play button. It toggles between the two. How do I get it to control the external SWF as well?

     

    On Frame 1:

    stop();

     

    pauseBtn.addEventListener(MouseEvent.CLICK, pauseMovie);

     

    function pauseMovie(e:Event): void {

        gotoAndStop(2);

         MovieClip(root).stop();

        MovieClip(MovieClip(root).myLoader.content).stop();  ///??????????

        }

     

    On frame 2:

    playBtn.addEventListener(MouseEvent.CLICK, playMovie);

    function playMovie(e:Event): void {

        gotoAndStop(1);

         MovieClip(root).play();

        MovieClip(MovieClip(root).myLoader.content).play();  ///????????????

    }

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Feb 5, 2013 3:47 PM   in reply to CEItim

    you're loading an as2 swf into an as3 swf.  you can't directly control the as2 swf.

     

    you must use localconnection to communicate between the two:  http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

     
    |
    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