Problem with Transitions between external SWFs

Hello, everyone,

I’ve been using Kirupa.com’s tutorial to “build transitions between external swfs,” and I’m hitting a wall. Maybe someone can help me.

Here is a summary of the situation. I’m using Flash MX 2004. I have a main file called Main_En.swf, which contains the empty movie clip container (_EN is for English, because I’ll have multiple languages eventually). Upon loading, Main_En.swf calls Welcome_EN.swf into the container. So far, no problems.

Main_EN.swf contains a movie clip symbol named “navigation,” inside which are the buttons that will call the other swfs (Links_EN.swf, Stories_EN.swf, etc.). That’s the rub: The swfs won’t load. I thought maybe it was because of the individual swf’s pre-loader code (also made from one of Kirupa.com’s tutorial) but I tried without it and the movies still failed to load.

Here is the Action Script associated with one of the buttons. All I did was copy/paste Kirupa’s code, then changed the file names, but maybe someone will spot an error. (By the way, is it OK to combine those rollOver/ rollOut commands? It seems repetitive to write it out all the time. …)

//Loads movie
on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = “Links_EN”;
container.loadMovie(“Links_EN.swf”);
} else if (_root.currMovie != “Links_EN”) {
if (container._currentframe >= container.midframe) {
_root.currMovie = “Links_EN”;
container.play();
}
}
}
//Button Animation
on (rollOver) {
tellTarget ("_root.Yin-Navigation.Yin-Links") {
gotoAndPlay(“Up”);
}
}
on (rollOut) {
tellTarget ("_root.Yin-Navigation.Yin-Links") {
gotoAndPlay(“Down”);
}
}
on (rollOver) {
tellTarget ("_root.Yin-Navigation.Genie-Links") {
gotoAndPlay(“Up”);
}
}
on (rollOut) {
tellTarget ("_root.Yin-Navigation.Genie-Links") {
gotoAndPlay(“Down”);
}
}
on (rollOver) {
tellTarget ("_root.Katana-1.Flare-1") {
gotoAndPlay(“Go”);
}
}

The “Links_EN” file has this code on its first frame:
midframe = 12;
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent100;
this.loadText = Math.round(getPercent
100)+"%";
if (bytes_loaded == bytes_total) {
this.gotoAndPlay(3);
}

This code is at the midframe:
stop();

And this code is on the last frame:
_root.container.loadMovie(_root.currMovie+".swf")

Well, I hope you’re not too cross-eyed by now. Thanks to anyone who chips in. I appreciate your time.

Are you sure you gave the container movieclip the instance name ‘container’ ? Also, are the buttons on the main timeline ? If not, then you’ll have to adjust the path to the container movieclip.

Yes to both questions.

On loading, Main_EN.swf automatically calls Welcome_EN.swf with this code:

_root.currMovie = “Welcome_EN”;
container.loadMovie(_root.currMovie+“.swf”);

And that works fine.

The buttons are in a movie clip symbol called “navigation” in Main_EN.swf’s timeline. Does it matter if the symbol has an instance name on the timeline? Right now, it’s called, uh, navigation.

Thanks for your reply.

The instance name of the button movieclip isn’t of great importance here, but it’s a good thing to give movieclips instance names. Since the buttons are in a seperate movieclip, you’ll have to adjust the path to the container movieclip (make sure it’s instance name is ‘container’, without the quotes). Like this:


on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = "Links_EN";
_parent.container.loadMovie("Links_EN.swf");
} else if (_root.currMovie != "Links_EN") {
if (_parent.container._currentframe >= _parent.container.midframe) {
_root.currMovie = "Links_EN";
_parent.container.play();
}
}
}

By adding ‘_parent’, we tell it to look up another level. Just container would look in the button movieclip ‘navigation’, and we need the parent movieclip of navigation which is _root, so we add _parent to the path.

Thanks a bunch! That did it. Now I can stop banging my head against the wall and return to some semblance of a life. If you’re curious about what you were helping me achieve, you might follow this link: http://www.mangamerica.com/test.htm

It’s still a work in progress. I’m not done designing/coding all the swfs (only the e-mail and links buttons are active). And for some reason, the preloaders don’t always show up, and when they do, the loading is almost done, which defeats the purpose. … Weird. … But your input definitely helped me clear a big hurdle, so thanks again!

Take care.

No problem … Didier is it ? :slight_smile: The preloader thingy is most likely because the content is already cached on your computer. Clear your cache, refresh and you should see the preloader again.

Hello, again,

A cached movie was my first thought, too, until I read elsewhere in these forums that certain components mess up preloaders because they export in the first frame, or something along those lines. I don’t know Action Script well enough to fix this.

Turns out, when I got rid of the scroll bars in the “Welcome” movie, the preloader worked OK. … My workaround is to use a button to click through the “What’s new” message. Not as practical, but it works.

Working with Flash is a neverending learning process for me. For every problem I fix, seems like two or three new ones pop up. Good thing there are people like you who know what they’re doing and don’t mind giving a hand to newbies like me. Thanks again.

Ah yes, components are exported in the library and that exporting happens before anything else - also before your preloader is loaded. That’s why the preloader isn’t there for a second.