Copy link to clipboard
Copied
I have a movie that loads different swfs on different frames. When the loaded movie is done, I want a next button that can tell the loader to go to frame 2.
Tried several methods. Any help would be greatly appreciated!
you must be changing your code to cause different error messages and that's making it difficult to help you.
if you leave the code in message 16, use:
MovieClip(this.parent.parent.parent).gotoAndStop(2)
in the loaded swf.
Copy link to clipboard
Copied
where's the code that determines when the loaded swf has completed play?
Copy link to clipboard
Copied
There will be a button that pops up on the last frame of the loaded movie. Trying to figure out the path to the parent...
Copy link to clipboard
Copied
after the loader is added to the display, you can use,
MovieClip(this.parent.parent)
to reference the main timeline of the loading swf. eg,
MovieClip(this.parent.parent).gotoAndStop(2);
Copy link to clipboard
Copied
Is that all the code I need? I get a coercion failed error.
Copy link to clipboard
Copied
is your code on the main timeline of the loaded swf?
Copy link to clipboard
Copied
yes. On frame 2. I get "Cannot access a property" when I run that swf, and the coercion error when I run the loader.
Copy link to clipboard
Copied
you can't 'run' that swf.
you publish it and it's loaded.
in your loading swf is your loader added to the display before loading is complete?
if so, what's the exact error?
Copy link to clipboard
Copied
I did a test movie and test/debug on the loaded (Step1) to see if it worked. Hit next and got the error. Is this not the right thing to do? It has the code you provided on the second frame. That is the only code associated with communication so far. The loader file is called "loader". Neither file seems to know anything is wrong until the loaded movie hits the second frame.
Copy link to clipboard
Copied
you can't 'test' the loaded fla. just publish it to create the swf.
then test using the main (loading) fla. if you see an error doing that, copy and paste your error and indicate the code referenced in the line number of the error message.
Copy link to clipboard
Copied
This is the error from the loader:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Sprite@7fffbee4f49 to flash.display.MovieClip.
at step_1_fla::MainTimeline/frame2()
at flash.display::MovieClip/nextFrame()
at step_1_fla::MainTimeline/next()
Frame 2 code:
MovieClip(this.parent.parent).gotoAndStop(2);
Copy link to clipboard
Copied
do you have a document class file for the loading (main) swf and does that class file extend Sprite instead of MovieClip?
Copy link to clipboard
Copied
There is currently no document class file
Copy link to clipboard
Copied
replace
Frame 2 code:
MovieClip(this.parent.parent).gotoAndStop(2);
with
Frame 2 code:
trace(this.parent);
trace(this.parent.parent);
trace(this.parent.parent.name);
Copy link to clipboard
Copied
[object ProLoader]
[object Sprite]
instance3
Copy link to clipboard
Copied
show your proloader code that adds it to the display and the relationship between the sprite parent of proloader and the main timeline.
Copy link to clipboard
Copied
the loader.fla file uses a UILoader, so there is no code. I created another file using object loader. That file uses this:
var swfLoader:Loader = new Loader();
var swfFile:URLRequest = new URLRequest("step_1.swf");
var container:MovieClip= new MovieClip();
swfLoader.load(swfFile);
container.addChild(swfLoader);
addChild(container);
That also fails. The traces are:
[object Loader]
[object MovieClip]
instance2
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@7fff9c15ea1 to flash.display.MovieClip.
at step_1_fla::MainTimeline/frame2()
Copy link to clipboard
Copied
you must be changing your code to cause different error messages and that's making it difficult to help you.
if you leave the code in message 16, use:
MovieClip(this.parent.parent.parent).gotoAndStop(2)
in the loaded swf.
Copy link to clipboard
Copied
The code in 16 is a completely new file. Decided to use code instead of the UILoader component. That was crucial. Still got an error, but it would have never worked with the component. Figured I would take that possibility of error out of the equation. But alas, that code worked perfectly. Just needed an extra .parent!
Thank you!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now