Help with transitions

Transitions
Every external swf will have an intro part, a part that shows the content, and an outro. So let’s say frame 1-77 intro, 78 stop, 79-160 outro for example. This will work together with the buttons on the main swf: when we click one of those buttons, we want the swf to play it’s outro. Let’s start from there an build our way to the final script.

So let’s say we have a movieclip called container on the main swf in which we load the sections. Then the script for the buttons will be:
ActionScript:

[AS]
on(release){
_parent.container.play();
}

[/AS]

But, we only want it to play when it has reached it’s frame at where it stops. How do we know ? We’ll place a variable in the external swf that holds the framenumber of the frame at which it stops, and then we’ll ahve the button check if it matches with it’s currentframe.

So add this to the first frame of every swf:
ActionScript:

[AS
midframe=78
[/AS]

Of course, I’m just taking 78 as example value here. And place this on your button
ActionScript:

[AS]
on(release){
if(_parent.container._currentframe == _parent.container.midframe){
_parent.container.play();
}
}
[/AS]

Ok. Now, we want to load another movie to container when the current section playing it’s outro has reached it’s last frame. But the external swf doesn’t know what button we clicked and therefore neither what swf it has to load. So we’ll store a variable in _root, so the section can access it too, that stores the movieclip to load:
ActionScript:
[AS]
on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = “work”;
_parent.container.loadMovie(“execution.swf”);
} else if (_root.currMovie != “work”) {
if (_parent.container._currentframe == _parent.container.midframe) {
_root.currMovie = “work”;
_parent.container.play();
}
}
}

[/AS]
And at the last frame of each of your swfs:
ActionScript:
[AS]
_root.container.loadMovie(_root.currMovie+".swf");
[/AS]

Notice that we are always loading [_root.currMovie].swf. Therefore, you must make sure that you only give the names of your swfs to _root.currMovie when pressing the buttons. So if you have the swfs a.swf, b.swf and c.swf for example, you must give _root.currMovie the values a b and c when pressing the buttons. Otherwise it will try to load non-exisiting swfs.

Now with my question. I don’t understand this section…
on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = “work”;
_parent.container.loadMovie(“execution.swf”);
} else if (_root.currMovie != “work”) {
if (_parent.container._currentframe == _parent.container.midframe) {
_root.currMovie = “work”;
_parent.container.play();
}
}
}

And at the last frame of each of your swfs:
ActionScript:

_root.container.loadMovie(_root.currMovie+".swf");

Notice that we are always loading [_root.currMovie].swf. Therefore, you must make sure that you only give the names of your swfs to _root.currMovie when pressing the buttons. So if you have the swfs a.swf, b.swf and c.swf for example, you must give _root.currMovie the values a b and c when pressing the buttons. Otherwise it will try to load non-exisiting swfs.

Can someone please explain what the different things mean? Sorry for the long post but this is 2 days of questions :slight_smile:

By the way I am composing a list of intermediate AS that all newbies (like me) should know.

Thank you VERY much for reading all of this.

Mike

and by the way, I found that AS for transitions on a post… IS there an official tutorial on kirupa for transitions ? I went through a couple of pages of search results and couldn’t find it. Does anyone have a link.

Mike

Claudio wrote one
http://www.kirupa.com/developer/mx/preloader_transition.htm

scotty(-:

why’ve you put it all in the as tags?

thanks scotty, I know this might sound really stupid but can you tell me what the exclamation marks in the code for? Thanks O and I searched the form and it didn’t show anything so thanks for the help

Mike

I’m converting that thread to a tutorial at the moment. It should be up in a short while.

The != is an operator that checks for inequality:

trace(5!=4);
//true
trace(5!=5)
//false

More info on the != operator can be found here.

Thanks a lot… In ur upcoming tutorial can you explain how to incorporate the loading bar (in another tutorial here at K). Or if you could tell me now that would be great! Thanks

All you need to do is add the preloader to your swf, before the intro. That’s all. You can find a preloader tutorial here.

yeah but doesn’t that mean the external swf has to be broken down into 3 main frames for the preloader to work? Then how wouild u set up the midframe and all that nice stuff? Thanks

Mike

You would indeed have to add frames. The preloader itself takes two frames, and at the third the intro begins. You can add an extra frame right before the preloader that defines the midframe. You can also place the midframe definition together with the preloader, but then it’ll be defined multiple times. That’s nothing too serious though. The choice is yours.

The midframe will remain the frame at which your intro stops and your content is shown. After you’ve added the preloader, you’ll have to update the midframe definition :slight_smile:

Other than that, nothing has to be changed.

Well how would the AS look when defining the midframe of a movieclip (we have to say the frame in a movieclip because the content with a preloader is only all in one movieclip right?) Can you give me an example or example SWF i could download somewhere. I learn better that way. Thanks

Mike

anyone…