• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Pause/Play for external SWF

Explorer ,
Feb 05, 2013 Feb 05, 2013

Copy link to clipboard

Copied

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();  ///????????????

}

Views

76.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 05, 2013 Feb 05, 2013

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, pauseMo

...

Votes

Translate

Translate
Community Expert ,
Feb 05, 2013 Feb 05, 2013

Copy link to clipboard

Copied

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();  ///????????????

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2013 Feb 05, 2013

Copy link to clipboard

Copied

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();  ///????????????

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 05, 2013 Feb 05, 2013

Copy link to clipboard

Copied

That fixed the error at runtime, but the pause does not work.

When I pressed the pause button, I got this error in the console:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@2a2080f9 to flash.display.MovieClip.

    at MyProject_fla::playPause_5/pauseMovie()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2013 Feb 05, 2013

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 05, 2013 Feb 05, 2013

Copy link to clipboard

Copied

Thanks for your help. I tried it but I got this error:

Symbol 'playPause', Layer 'actions', Frame 1, Line 91119: Access of possibly undefined property myLoader through a reference with static type flash.display:DisplayObject.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines