Skip to main content
Known Participant
May 27, 2008
Frage

Targeting of movie clip not working

  • May 27, 2008
  • 5 Antworten
  • 543 Ansichten
from a frame action, I am loading a movie in to an empty movie clip named "container_mc"
Then I wish to go to a specific label in the swf file I loaded in that container_mc clip.

The first statement works, the movie loads properly in the container_mc. However the second statement does not work: it just stays at frame 1. I did make sure there was a label named "montreal" in the loaded swf. Any suggestion?

Thanks,

Yvan
Dieses Thema wurde für Antworten geschlossen.

5 Antworten

clbeech
Inspiring
June 1, 2008
no offense Noel - but the MovieClipLoader class is far superior to loadMovie - and unfortunately I see the error in my code above :( we need the listener...

so danycom add the following line after the first declarations:

var mcl = new MovieClipLoader();
var lstn = new Object();
mcl.addListener(lstn);

sorry about that :)

Noelbaland
Participating Frequently
May 30, 2008
Hello,

Try creating a global variable in the quebec movie and then test for the variable in the main movie first before going to the "montreal" frame.

For example

(All Actionscript 2)

[quebec.swf]
_global.allLoaded = 1;

[main.swf]

_root.createEmptyMovieClip('container_mc', 1);
_root.container_mc.loadMovie('exported_clips/quebec.swf');

_root.onEnterFrame = function() {
if (_root.container_mc.getBytesLoaded() >= _root.container_mc.getBytesTotal()) {
// Test for global variable here
if(allLoaded == 1){
_root.container_mc.gotoAndStop("montreal");
delete this.onEnterFrame;
}
}
}

See if that works
Known Participant
June 1, 2008
I tried your code and the result is the same. It does load the movie in the clip but it does not go to the montreal label. Is it possible that one of my files be corrupted in some way that would make the process not work? Maybe I should recreate all from scratch, or would I just be wasting my time doing that?

Thanks anyway.

Yvan
Known Participant
May 29, 2008
I tried all your suggestions. No luck! It loads the movie in the container_mc clip but it does not go to the "montreal" label. I even tried the frame number instead of the label, still does not work. I added a button in the clip that links to the "montreal" label and that works, but I must click the button. What I want is to go to that label after the clip has loaded.

Yvan
Damon Edwards
Inspiring
May 28, 2008
Use the MovieClipLoader class, and not the way that was just suggested. The class has methods for checking the load progress, when the load completes, and when the asset initializes. Here is an example
http://forums.flashgods.org/as2-loading-external-swfs-t70.html
Known Participant
May 29, 2008
Thanks very much to all of you. I guess I have something to chew on now; I will try this.

Yvan
Participating Frequently
May 28, 2008
You are referencing something immediately after loading it.
Flash needs time to load the clip, and initialize it (even when working offline).

I can't remember the elegant way of doing it, but you could do this:

loadMovie("exported_clips/quebec.swf", container_mc);
this.onEnterFrame = function() {
//Wait for it to be finished loading
if(container_mc.getBytesLoaded() == container_mc.getBytesTotal()) {
container_mc.gotoAndStop("montreal");
delete this.onEnterFrame;
}
}

Note here that I didn't put the enterFrame directly on the container_mc, after you call the loadMovie you throw that mc's properties out the window. So I applied it to the root (or wherever this code is going).

Hope this helps out
clbeech
Inspiring
May 28, 2008
a better way to implement the load and trigger the call once the load is complete is to use the MovieClipLoader class and the onLoadInit handler, you do this like the following:

EDIT: LMAO d!
Participating Frequently
May 28, 2008
Aha, yes thats the elegant solution I was thinking of.
Thanks for reminding me ;)