# Help with transitions

**URL:** https://forum.kirupa.com/t/help-with-transitions/42997
**Category:** Uncategorized
**Created:** [February 17, 2004, 8:56pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997 "2004-02-17T20:56:26Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mlkedave](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mlkedave](https://forum.kirupa.com/u/mlkedave)
#### Post date: [February 17, 2004, 8:56pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997/1 "2004-02-17T20:56:26Z")

</div>

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 🙂

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 17, 2004, 10:28pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997/2 "2004-02-17T22:28:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2004, 8:13am UTC](https://forum.kirupa.com/t/help-with-transitions/42997/3 "2004-02-18T08:13:37Z")

</div>

Claudio wrote one  
[http://www.kirupa.com/developer/mx/preloader\_transition.htm](http://www.kirupa.com/developer/mx/preloader_transition.htm)

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2004, 9:16am UTC](https://forum.kirupa.com/t/help-with-transitions/42997/4 "2004-02-18T09:16:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2004, 12:48pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997/5 "2004-02-18T12:48:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2004, 2:20pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997/6 "2004-02-18T14:20:41Z")

</div>

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:

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

```

More info on the != operator can be found [here](http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary008.html).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 19, 2004, 8:18pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997/7 "2004-02-19T20:18:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 19, 2004, 8:31pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997/8 "2004-02-19T20:31:38Z")

</div>

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 🙂

Other than that, nothing has to be changed.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 19, 2004, 8:51pm UTC](https://forum.kirupa.com/t/help-with-transitions/42997/9 "2004-02-19T20:51:41Z")

</div>

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
