Transitions between External Movies
         by Voetsjoeba

 

This is a continuation of the tutorial found on the previous page. If you stumbled here via a search result, please finish the first page of this tutorial first by clicking here.

 

Setting up the main movie:

  1. Open your main movie in Flash. Right-click a button which will load the external movie into the main movie. Select Actions from the menu that pops up. The Actions dialog should appear.

  2. Copy and paste the following code into the Actions dialog box:



  3. Some modifications have to be made to the actionscripting (yes, yet again ) skins is the name of the movie you want to load when this button is clicked. Remember those movienames we used in the previous page ? Well, here's where we're using them. Of course, this value is different for each button. We don't want every button to load the same page do we ?
     

  4. Repeat step i, ii and iii for each button.

  5. It is essential that an external movie autoloads when entering the main movie. The reason for that can be read in the How and Why explanation below. To achieve this, add the following actionscripting to the frame that, when reached, you want the external movie to autoload. (which has to be a keyframe ! If it isn't a keyframe yet, select it and hit F6) of the main movie:



    And of course, the part home of home.swf has to be one of the names of the external movies, which we used at the previous page. If you don't understand, see the example names given at the previous page in step viii. For those examples, home.swf could be replaced by profile.swf, news.swf, home.swf, work.swf and portfolio.swf.

Adding a preloader with a bar:

 

To preload an external movie with a bar before playing the external movie, use this tutorial by Shane Waldeck (Lostinbeta). Apply it to the external movie you want to preload before displaying.

 

Congratulations ! You've finished creating transitions between external loaded movies ! Now for what might be the most important part: how and why ? I'll explain how this works to you:

 

Download Source file for MX

 

 

How and why it works:

When an external movie is loaded inside a main movie, the external movie will also use the main movie's _root. So what I did is make the main movie write a var to the _root, which is then read by the external movie. This way the two movies can communicate.

 

The code on the new movieclip in the external movie is used to check if the variable written by the main movie has changed. Since every button of the main movie changes that variable, it will basically check if another movie has to load into the main movie. If it has changed (which means that another movie has to be loaded now), the external movieclip will start playing the first frame of the outro.

 

The reason why the other movie can't be on the stage anymore when it plays the the outro, is because of the onClipEvent(enterFrame). This practically equals all the time. So what will happen if it wasn't of the stage ? It would keep giving the command to gotoAndPlay, which would make the movie freeze at the frame you told it to play.

 

Because the movie is of stage from the outro on, it won't keep giving the command to gotoAndPlay. And so, the movie will continue. When the outro reaches it's last frame, it gives the command to load another movieclip into the main movie. And then the intro animation of the other external movie is played, which makes a nice transition.

 

When the command is given to load another movie, the movie that is loaded now will automatically make place for the new one. So don't worry that the other movie will still be there when a new one has loaded.

 

For the autoload option of part v, the reason that you can't use _root.curmovie+".swf" like we did for the external movies, is simply because the var doesn't exist yet when first entering the page. It is created by the buttons when clicked, or by an external movie when played. Because of that reason, it is essential that an external movie autoloads when entering the main movie. But that won't be a problem, as nobody wants to see an empty space when entering a site.

 

Remember that, if you put this online, it is prefered to put all the swfs in the same folder. If not, the external movies won't be found. It is possible to change it, but if you don't really need them to be in different folders, just keep them in the same.

 

That's it. If you have any further questions, please don't hesitate to post them on the forum. You can also contact me by e-mail, my e-mail address is given below.

 

Hope this helps

Voetsjoeba.

[email protected]

 

 

 Previous Page
 

 

 



SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.