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(); ///????????????
}
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
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(); ///????????????
}
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(); ///????????????
}
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()
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks for your help. I tried it but I got this error:
Symbol 'playPause', Layer 'actions', Frame 1, Line 9 | 1119: Access of possibly undefined property myLoader through a reference with static type flash.display:DisplayObject. |