How to make a Flash website with smooth transitions
Author: Bill Trikojus
| |
|

|
Document setup
|
| |
OK here's a tute to show you how to use loadMovie and still get smooth transitions between sections on your site. Below is what you will be making -
This uses a similar concept to the file found here.
You can download the source files for this tute here.
OK load Flash MX. The default stage size and background colour of the new document will be fine but change the frame rate to 21. Make 2 new layers and name the 3 layers "actions", "buttons" and "preloader graphics".

|
| |
 |
Progress bar
|
| |
Click on frame one of the preloader graphics layer and draw a 150X10 rectangle down the bottom lefgt corner of the stage. Select the rectangle and convert it to a movieclip. Name it progressBarMC and make sure that its registration point is set to center left.
Click OK. Give the new mc an instance name of progressBar (this is case sensitive!!). Underneath the progress bar but still on the preloader graphics layer, type the word "loading" using static text. Next to the loading text, make a dynamic text box with a variable name of percent. Type anything you want into this text box just to get the look and placement right - whatever you type will never actually be visible as we will tell flash what to display in the text box.
OK select all 3 items on the preloader graphics layer and hit F8 it put them inside a movieclip. Name this new movieclip preloaderGraphicsMC and set the registration point to the center.
Click OK and give the new mc an instance name of preloaderGraphics.
Now would be a good time to save your file. Save it as main.fla into a folder named smoothTransitions.
|
 |
| |
 |
Button template
|
| |
| |
Now click on frame 1 of the buttons layer and down the bottom of the stage draw yourself a button. Select what you just drew and convert it to a button. Name it buttonTemplate
Click OK and give the new button an instance name of button1. Go inside the button and give it an over state if you wish. Make 2 copies of the button on the stage change the instance names of the new buttons to button2 and button3.
|
 |
 |
| |
 |
Main file
|
| |
| |
OK back to the main.fla. Paste these actions into the first frame of the actions layer
//stop this timeline
stop();
//hide the preloader
preloaderGraphics._visible=false;
//initialise a variable
nextMovie="content1.swf";
//load the starting movie into level 1
loadMovieNum(nextMovie,1);
//button1 actions
button1.onRelease=function(){
//this makes sure that content 1 isn't already loaded
if(nextMovie!="content1.swf"){
//set the variable that holds the name of the movie to be loaded
nextMovie="content1.swf";
//tell the currently loaded content movie to play it's outro animation
_level1.gotoAndPlay("outro");
}
}
//button2 actions
button2.onRelease=function(){
//this makes sure that content 1 isn't already loaded
if(nextMovie!="content2.swf"){
//set the variable that holds the name of the movie to be loaded
nextMovie="content2.swf";
//tell the currently loaded content movie to play it's outro animation
_level1.gotoAndPlay("outro");
}
}
//button3 actions
button3.onRelease=function(){
//this makes sure that content 3 isn't already loaded
if(nextMovie!="content3.swf"){
//set the variable that holds the name of the movie to be loaded
nextMovie="content3.swf";
//tell the currently loaded content movie to play it's outro animation
_level1.gotoAndPlay("outro");
}
}
Have a read of the comments - they should explain what's going on pretty clearly. Basically the buttons set a variable that stores the name of the next movie to be loaded, and also tell the currently loaded content to play its outro animation.
Test your movie.
It should work like the one at the top except that the preloader graphics won't load - you need to upload your files and view them online see the preloader.
Obviously the transitions in this tutorial are very basic but look around online and you will see that all good flash sites have smooth transitions between sections - so use your imagination and do something interesting with the concepts covered in this tute.
cheers
PS I added photos to my content as well - just to increase the file size of the external swfs so I could see that the preloader was working correctly.
PPS I have attached 2 extra source files that show how to set up basic website Flash structures. One shows how to achieve a smooth transition by covering the current content with a box, the other uses a similar method to that outlined in this tutorial but is a more solid structure that will not jump if the user clicks on multiple buttons in quick succession. These files require Flash CS3.
PPPS To learn more about creating websites in Actionscript 1.0 check out 'ActionScript for Flash MX: The Definitive Guide ' by Colin Moock.
|
Back
Share
Like this? Click a link below to share it...




Subscribe and Download
Comments
2008-10-15: vimo said:hi, nice tut!
do you know why i get a sintax error in line 13 on the content.swf: _level0.preloaderGraphics.percent = int(Percentage) add "%";?
cheers!
2008-10-15: Bill Trikojus said:Try changing it to
_level0.preloaderGraphics.percent = int(Percentage) + "%";
cheers
2008-10-15: vimo said:hmm not working, dunno what might be wrong... sorry, im a newbie in AS.
the curious thing is that it worked before as the code is written on the tutorial, then appear that error...
then i tried to make another external swf (content2.swf) based on the first one but got into trouble.
2008-10-15: Bill Trikojus said:Did you copy and paste the code as it appears on this discussion or from the email that gets sent? In the email it adds lots of \\ that shouldn't be there
2008-10-15: vimo said:did it from the tutorial
2008-10-15: vimo said:i think i know the cause...
ur file is set up for flash player version 6... n i have been trying to load it on flash player version 8
2008-10-15: Bill Trikojus said:Yep it has something to do with that. Changing add to + fixed it for me. try changing the int to Math.round()
cheers
2008-11-16: CoryLit said:Heya thanks heaps for your tutorial it's great... for us novices! I was wondering how would I get the content swf's to load into a Loader component?
Thanks in advance for any help, you're great!
2008-11-24: JesperAndreassen said:Hi Bill,
great tutorial :)
How do I make this work if I want the content to be loaded into a movieclip (container_mc on the main timeline) instead of levels?
2008-11-24: Bill Trikojus said:Hi Jesper
Pretty sure this tute does that
Building a Flash website
cheers
2009-05-01: Jon Ada said:This tut is great. Does anyone know where there is an actionscript 3 version of this?
2009-05-09: Tania said:hi, bill, this tute is the only one I've found to do that with levels, thanks for that, just a question, I build my site with a base on level 0, all the sections will be load on level 1 and my main menu on level 2 cause it´s transparent and I want it above all,
what changes could i do on the code to make it work for me?
2009-05-09: Tania said:... another thing, my buttons are inside movie clips...
2009-05-22: nonaim said:This is Great Bill! Wondering if you have a AS3 version of this?
2009-05-22: Bill Trikojus said:Not at this stage unfortunately.
Post a comment
Garbage posts and SPAM will be deleted.