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

how to have loaded movie communicate with loader

Contributor ,
Aug 09, 2016 Aug 09, 2016

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!

TOPICS
ActionScript
1.3K
Translate
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 , Aug 16, 2016 Aug 16, 2016

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.

Translate
Community Expert ,
Aug 09, 2016 Aug 09, 2016

where's the code that determines when the loaded swf has completed play?

Translate
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
Contributor ,
Aug 09, 2016 Aug 09, 2016

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...

Translate
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 ,
Aug 09, 2016 Aug 09, 2016

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);

Translate
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
Contributor ,
Aug 09, 2016 Aug 09, 2016

Is that all the code I need? I get a coercion failed error.

Translate
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 ,
Aug 09, 2016 Aug 09, 2016

is your code on the main timeline of the loaded swf?

Translate
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
Contributor ,
Aug 09, 2016 Aug 09, 2016

yes. On frame 2. I get "Cannot access a property" when I run that swf, and the coercion error when I run the loader.

Translate
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 ,
Aug 09, 2016 Aug 09, 2016

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?

Translate
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
Contributor ,
Aug 15, 2016 Aug 15, 2016

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.

Translate
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 ,
Aug 15, 2016 Aug 15, 2016

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.

Translate
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
Contributor ,
Aug 15, 2016 Aug 15, 2016

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);

Translate
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 ,
Aug 15, 2016 Aug 15, 2016

do you have a document class file for the loading (main) swf and does that class file extend Sprite instead of MovieClip?

Translate
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
Contributor ,
Aug 15, 2016 Aug 15, 2016

There is currently no document class file

Translate
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 ,
Aug 15, 2016 Aug 15, 2016

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);

Translate
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
Contributor ,
Aug 15, 2016 Aug 15, 2016

[object ProLoader]

[object Sprite]

instance3

Translate
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 ,
Aug 15, 2016 Aug 15, 2016

show your proloader code that adds it to the display and the relationship between the sprite parent of proloader and the main timeline.

Translate
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
Contributor ,
Aug 16, 2016 Aug 16, 2016

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()

Translate
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 ,
Aug 16, 2016 Aug 16, 2016

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.

Translate
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
Contributor ,
Aug 16, 2016 Aug 16, 2016

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!

Translate
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 ,
Aug 16, 2016 Aug 16, 2016
LATEST

you're welcome.

Translate
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