Email:
Name:
 
learn web design
Free Tutorials Send by Email
Free Web Design Newsletter
Opportunities to Win Free Prizes
Subscription to our RSS Feed
Flash Website Tutorial

Flash Website Tutorial

Posted on 28. Jun, 2008 by Michael in Flash

Creating a flash website using actionscript 2.0

Download PSD Download FLA

Result of the flash website tutorial, click to view in flash:

Step1 – Making a Flash Preloader

Open a new flash file.

And give it these settings.

First we are going to make the preloader.
Make a new movie clip. Insert —>> New Symbol (Ctrl+F8)

Now you are in the preloader movie clip.

And make 3 layers with 100 frames. Name the maskT, text and textW.

Make another symbol and call it loading_mc.

In that movie clip type in loading.

Once you have made that movie clip then duplicate it. And call it loading1_mc.

And in that movie clip make the text green.

Now open your preloader_mc and drag the movie clip loading_mc on to the stage.
Make sure that you are in the layer textW.

Don’t forget to center it on the stage.

And in the layer called text you drag the loading1_mc into it. And center
it.

Now in the first frame of the maskT layer we will draw a rectangle. Like
this.

Still in the maskT layer go to frame 100 and right click to convert to key
frame.

Now drag the rectangle on top of the text.

Place your cursor in between frame 1 and 100 from the maskT layer, right click
and add a motion tween.

Now move with the cursor on the layer, right click and select mask.
This will add the layer text under the mask.

Now go back to your scene1 and change the name of the first layer to preloader.

Now drag your preloader_mc onto the stage.

While in the first layer press F9 to open up the actions window. Click on the movie
clip in the stage and the paste this in the window.



onClipEvent (load) {
total = _root.getBytesTotal();
}
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
perc1ent = int(loaded/total*100);
perc1 = “”+perc1ent+”%”;
gotoAndStop(perc1ent);
if (loaded == total) {
_root.gotoAndPlay(2);
}
}

Now click on the layer and go to the actions window and give it this code

stop();

Now make a second layer and convert it to a key frame.(F6) and paste this code.

This code tells flash to check the bytes that are loaded .if it’s loaded then go
to frame3 if not stay in frame 1.

You may think what happened to frame2 . Well you are in it.

if(_root.getBytesLoaded() ==
_root.getBytesTotal()){
gotoAndPlay(3);
}
else{
gotoAndPlay(1);
}

Step 2 – Making the Smooth Page Transitions

Start by importing your PSD to flash, if you do not know how to do this, read our Importing Images in to Adobe Flash Tutorial.

href=”http://www.webdesigndev.com/flash/importing-images-in-to-adobe-flash”>
Now make a new movie clip and name it content_mc. And drag the square
on it.

Now make a second layer in scene1 and call it content.
Click on the third frame and press F6 to make it a key frame.

Now drag your content_mc to the stage and center it horizontal.

Select frame 15 and convert it to a key frame. Now right click between frame
3 and 15 and make a motion tween.

In frame 3 and change its brightness to -100%

lets make the pages first. the content to fill these is up to you. I will show
you how to do those page transitions that so many people want to know.

I will show you a very easy way to do this.

Lets me the pages first . make a new movie clip and call it homePage_mc.

Make a layer for each thing that you add. Will be allotting better if you
want to change some things later on.

I have 2 layers. a layer with bigger text and the some text to fill this page.

Now change some text for the other pages . Since I don’t use this site I will
only change the main text .

So you will see that the pages change. Once you made all the pages we will implant
them into scene1.

So go to scene1 and add 2 new layers , call it pages
and the other 1 actionsMain.
.
First insert frames on frame 140 for the layers content
, pages and actions.
Add a stop(); in the actionsmain on frame
35.

In the pages layer you need to add key frames . So when we link the buttons
that know where to go to.

Add key frame in the following frames : 35 , 45 , 54 , 59 , 69 , 78 , 82 , 92,
101 , 105 , 115 , 124

Now do the same for the actions layer.

It should look like this.

In the pages layer select frame 35 . Now drag your homePage_mc on the stage and
place it like this.


Copy frame 35 and paste in frames 45 and 54.

Now change the alpha of the movie clip homePage_mc to 0%.


Now right click between 35 and 45 and 45 –54 and add a motion tween.
Like this.

Add the other movie clips to the other key frames. After that you have this.


Select your actionsmain layer and in the key frames 45 , 69 , 92 and 115 add a
stop in your action script.
This is to make sure that it doesn’t loop all the time.
stop();
And now label the frames.
35 = home
59 = about
82 = port
105 = contact

Now comes the tricky part. All the AS . you need to get this right or we will
get allot of errors. :-(
All of this will go in the actionsmain layer. . So when the page opens the
buttons are already in pause state.
Code for frame 36
home_mc.gotoAndStop(”pause”);//if you hit this frame then the button
will go to the pause state
over1_btn.enabled= false ; //here you say that when you go over that button
it can’t do anything

frame 60
about_mc.gotoAndStop(”pause”);
over2_btn.enabled= false ;

frame 83
port_mc.gotoAndStop(”pause”);
over3_btn.enabled= false ;

frame 106
contact_mc.gotoAndStop(”pause”);

over4_btn.enabled= false ;

Now we will tell flash were to go when a button is released. And we will give
it a little timeout. If you put in 1000 then that’s 1 second.
So we will give in 500 , that’s a half second.
Code for frame 54
stop();

function moveOn()
{
gotoAndPlay(target);

}
setTimeout(this, “moveOn”, 500);// this will delay the transition
by 1/2 second
over1_btn.enabled= true ; //this will make sure that the button works again

home_mc.gotoAndPlay(”h2″); //and that the button play’s the rest
of the animation

Frame 78
stop();

function moveOn()
{
gotoAndPlay(target); //this is were the flash will go after you clicked a
button

}
setTimeout(this, “moveOn”, 500);
over2_btn.enabled= true ;
about_mc.gotoAndPlay(”h2″);

Frame 101
stop();

function moveOn()
{
gotoAndPlay(target);

}
setTimeout(this, “moveOn”, 500);
over3_btn.enabled= true ;
port_mc.gotoAndPlay(”h2″);

Frame 124
stop();

function moveOn()
{
gotoAndPlay(target);

}
setTimeout(this, “moveOn”, 500);
over4_btn.enabled= true ;
contact_mc.gotoAndPlay(”h2″);


This is
what you should have now.

Step 3 – Enable and Disable Buttons

Again make a new symbol , and name it home_mc. Now make 4 layers. Call them left , right , text and actions.

In the text layer type in home and the select that text and press

F8 to convert it to a movie clip. name this homeText_mc

Now in your movie clip home_mc Add this image. to layers left and right in
the first frame.

Convert it to a movie clip called indi_mc.

And place them on the side of the text.

Add a key frame in frame 7 of the layers left and right.

Go back to the second frame and move the indi_mc away from the text by 15
pox each. 1 to the left the other to the right.

And give them in the first frame 0% alpha. Now copy these 2 frames and paste
them in to frame14.

And give it a between the key frames a motiontween.


Now give frame 8 a key frame in the layers left , right and actions.

In the actions layer give in stop(); in
the first frame , frame 7 and give frame 1 label h1
, frame7 pause and frame 8
style=’color:#00CC00′>h2
.

You should have this now.

Now you have to do the same with the other buttons.

When you have that then go to scene1 and add a folder. And call it buttons.


And add 8 layers and place them in that folder.

Now give them the names like below.

Make key frames in these 8 layers . In frame 23.

Now drag the buttons you just made in the right layer. homeB =
style=’color:#00CC00′>home_mc
, aboutB = about_mc
, ….

And now drag the swirls into position. Select the each and give them these
names and put them in the right layer.

Give these movie clips instance names. So that flash knows that you mean them
in the action script.

Do this for the other movie clips too. Name them the same as the movie clips.

Now we are going to make a button. Like this.

Drag that button into the layer inviB in scene1.and place it right on top of
the home_mc. Now copy and paste the button 3 more times and place

Them on top of the other 3 movie clips. And name them like below.


Now with those 4 buttons selected put the alpha to 0%.

Make a new layer on top of the rest and call it buttonactions. And give it
this code.

I
n this code you will say what flash needs to do when you go over , or press ,
… a movie clip.

//button home_mc//
over1_btn.onRelease = function(){
play();
target=”home”;
}
over1_btn.onRollOver = function(){
home_mc.gotoAndPlay(”h1″);
}
over1_btn.onRollOut = function(){
home_mc.gotoAndPlay(”h2″);
}
over1_btn.onReleaseOutside = function(){
home_mc.gotoAndStop (”pause”);
}
//button about_mc//
over2_btn.onRelease = function(){
play();
target=”about”;
}
over2_btn.onRollOver = function(){
about_mc.gotoAndPlay(”h1″);
}
over2_btn.onRollOut = function(){
about_mc.gotoAndPlay(”h2″);
}
over2_btn.onPress = function(){
about_mc.gotoAndStop (”pause”);
}

//button port_mc//
over3_btn.onRelease = function(){
play();
target=”port”;
}
over3_btn.onRollOver = function(){
port_mc.gotoAndPlay(”h1″);
}
over3_btn.onRollOut = function(){
port_mc.gotoAndPlay(”h2″);
}
over3_btn.onReleaseOutside = function(){
port_mc.gotoAndStop (”pause”);
}
//button contact_mc//
over4_btn.onRelease = function(){
play();
target=”contact”;
}
over4_btn.onRollOver = function(){
contact_mc.gotoAndPlay(”h1″);
}
over4_btn.onRollOut = function(){
contact_mc.gotoAndPlay(”h2″);
}
over4_btn.onReleaseOutside = function(){
contact_mc.gotoAndStop (”pause”);
}

Let’s make the animation when the buttons enter the screen.

Select the topL_mc and place it right above your screen.And place the
buttomL_mc right under it.

Now add a key frame in frame 33 for those 2 layers .In frame 33 move them on
how they were from the beginning.

Click between frame 23 and 33 and a motiowtween.

Now for the mask. add a key frame in 23 and draw a rectangle that will cover
your buttons.

Make a key frame in 33 and go back to 23 and place it like this.

And add a motiontween.

Now for the last piece . The header/logo. You can use any logo or banner you
want . This is to show you how you can tween with AS.

So take the logo and make it a movie clip.

And call it logo_mc

Make a new layer in scene1. make a key frame in frame 10 and drag Logo_mc
into the stage and place it on the left side.

Take a look on the Y axis.

Select the logo and press F9 to open Up the actions window. And give this code.

The first part will tell the movie clip where to start. and the second 1 will
say where to stop.

onClipEvent (load) {
//here you say where to start
this._y = -170;
}
onClipEvent (enterFrame) {
//this will tell the As on were to stop the animation. the 25 is what speed
you want it to move.
if (this._y<100) {
this._y += 25;
}

}

SO , press Ctrl+enter and you are done.

You should have learned some new but very simple things that you can use to
make your own site.

Visit later for more tutorials.

Tags: , ,

35 Responses to “Flash Website Tutorial”

  1. Kenny

    06. Aug, 2008

    Michael, I would like to thank you for this Flash Tutorial. However, What I can tell you here after I read your tutorial! Not clear enough to understand.

    Thanks

    Reply to this comment
  2. Dr!ver.

    07. Aug, 2008

    What do you mean ” not clear to understand”?

    Dr!ver.

    Reply to this comment
  3. Kenny

    07. Aug, 2008

    not clear enough to understand -> I.E:

    Now make a second layer in scene1 and call it content.
    Click on the third frame and press F6 to make it a key frame.

    Now drag your content_mc to the stage and center it horizontal.

    Reply to this comment
  4. Dr!ver.

    07. Aug, 2008

    really ?

    You have trouble understanding that ?

    Dr!ver.

    Reply to this comment
  5. Kenny

    08. Aug, 2008

    hmm… i’ve figured it out now.. thanks and sorry for false information. However, do you have msn? mind to have a chat? few question to ask u if you do not mind.

    Thanks

    Reply to this comment
  6. Dr!ver.

    08. Aug, 2008

    you can contact me if you click on my name.

    Dr!ver.

    Reply to this comment
  7. Kenny

    10. Aug, 2008

    I’ve tried to click on your name but it bring me to http://www.your-design.be/ ???

    Reply to this comment
  8. Dr!ver.

    11. Aug, 2008

    yep , you can contact me through that site.

    Dr!ver.

    Reply to this comment
  9. mike

    16. Aug, 2008

    How about having this again in AS3.0?
    Thanks in advance ;-)

    Reply to this comment
  10. David

    25. Aug, 2008

    I’m up to the section where you add the first block of code. However, when I try to add your code to preloader_mc, it says that code cannot be added to it. In fact, there is nowhere that I can enter the code. Where the normal input box is, it says “Current selection cannot have actions applied to it” in reference to preloader_mc. I checked and it is a movie clip so it should be able to have actions applied.

    Any ideas on what I’ve done wrong? I’m using CS3 and I see that you’re using an older version which may be the cause for my problem.

    Reply to this comment
  11. Ray

    29. Aug, 2008

    yeah same problem with david..

    Reply to this comment
  12. Dr!ver.

    01. Sep, 2008

    I use CS3 also . Only i do this in AS2 .

    Make sure that you selected the movieclip when you want to add the code .

    Dr!ver.

    Reply to this comment
  13. Peter

    11. Sep, 2008

    Hey im using this for the basis of an ict project in college but im having problems with the buttons. Its all implemented correctly with no errors but they wont work. Is this because im using MX 2004? The AS seems to recognise all the commands.

    Thx

    Reply to this comment
  14. jicsaw

    16. Sep, 2008

    thanx man…nice tut

    Reply to this comment
  15. Aaron Streich

    22. Sep, 2008

    Hello, first and foremost thanks for the tutorial!! It’s working… but as of now.. the loading graphic does not load until roughly 50%…. then the viewer only sees the last 50% of the load… any ideas??

    Reply to this comment
  16. Sou

    16. Oct, 2008

    I’m having a bit of trouble with one of the earlier steps… How do you change the brightness of a frame? This was under step 2 – making smooth page transitions.

    I tried changing the alpha value, but it changed the alpha value of all other frames on the layer as well.

    Reply to this comment
  17. Bob Lee Swagger

    28. Nov, 2008

    how about attaching the fla file to the end of the tutorial, so I dont have to read all that bullshit.

    I dissect pratical FLA files faster than I read.

    peace out biatches

    Reply to this comment
  18. Ad

    02. Dec, 2008

    How do i put it into my webpage?

    do i need to upload it into a flash uploader website?

    Thanx

    Reply to this comment
  19. Ad

    02. Dec, 2008

    also if i wanna put link in the text, do i write the code while writing it in flash or not?

    Reply to this comment
  20. Deepak

    23. Dec, 2008

    Thanks so much for this tutorials.

    Reply to this comment
  21. Wahha

    23. Jan, 2009

    I am having the same problem as Peter is. I can’t get the buttons to work. I checked over the code over and over again and redid the entire tutorial three different times, and no go.

    Reply to this comment
  22. mheav

    25. Jan, 2009

    hello sir!!!!!!!!
    wow was amazing!!!!!!!!!!!!
    i used to know what must be done for making a flash website!!!
    i tried differnt things to learn them!! such that
    i traced swf and fla files of websites and i tried method of reverse engineering …..
    but i never got it on my mind!!!!!!!!!
    thanks

    Reply to this comment
  23. AR

    09. Feb, 2009

    Now click on the layer and go to the actions window and give it this code

    stop();

    I’m a total beginner so please help me, I don’t get it when you say “click on the layer and go to the actions window”. Which layer and where is the action window?

    Is the layer the black screen one which has “loading” text in it and just paste the code?

    Reply to this comment
  24. Tane

    13. Feb, 2009

    is it possible to take content selection from another file

    like if i change other file the content changes too

    Reply to this comment
  25. HirenModi

    17. Feb, 2009

    Very good, Thanks.

    Reply to this comment
  26. Heet

    04. Mar, 2009

    amazing man i m finding this types of tuto. from long time i now i got thanx thanx thanx thanx thanx i m also trying for feedback form

    Reply to this comment
  27. Jobert

    07. Apr, 2009

    This Is Very Hard, i work for a mexico cheese factory they want me to make this thing for the site, but i cant do it, its realy realy… hard is there any other way to do this?
    or am i just realy not in to it gives me headache so much, that i ate all the cheese in the factory. thanks for the tutorial appreciate it.

    Joberto V. Halasas
    9222, Estico Ave, Mexico City

    Reply to this comment
  28. Jobert

    07. Apr, 2009

    Elo my name is Joberto Jobert for short i work at a cheese factory over mexico its realy fun but when they pushed me to make their website it was not good because i no good in computers this project help me alot thank for uploading it essay always be here for us help us anytime thats realy great.

    Joberto V. Halasas
    2999 Hecito Ave, Mexico City, 1234

    Reply to this comment
  29. jai

    11. Apr, 2009

    very us full your site
    thank you so much

    Reply to this comment
  30. anjo

    06. May, 2009

    this is very helpful…..but do you have a video tutorial for this….plz email me if anyone has a video for this tutorial

    Reply to this comment
  31. sergio

    19. May, 2009

    Hi m8 the thing i get confused whit one pictures that said pages pages i mean you have to pages and the actionmain you only have one stop i just wanted to know if you did a mistake there and confused the pages whit the actionmain pleas try to reply :) and the rest is an cool tutorial

    Reply to this comment
  32. regina maria

    19. May, 2009

    hey , my preloader doesnt take me to the next movie clip when I “test movie”.

    Do you have any idea what i did wrong?

    thanks

    Reply to this comment
  33. Skyler

    05. Jun, 2009

    I can’t get my buttons to work properly. The animation doesn’t play when I hover over them, and they won’t go to where they’re suppose to when I click on them. I followed the tutorial as much as I could, any ideas what might be causing them to not work?

    Reply to this comment
  34. tanweer

    06. Jun, 2009

    IN STEP 3

    In the actions layer give in stop(); in
    the first frame , frame 7 and give frame 1 label h1
    , frame7 pause and frame 8
    style=’color:#00CC00?>h2.

    You should have this now.
    (and here is the screenshop)… is it right according to the instruction???

    and also,
    what is this dudes,
    Make key frames in these 8 layers . In frame 23.
    Now drag the buttons you just made in the right layer. homeB =
    style=’color:#00CC00?>home_mc , aboutB = about_mc
    , ….

    Reply to this comment
  35. Dave

    24. Jun, 2009

    I’m using flash CS4 and for some reason when I try to create the first preloader motion tween it asks if I want to convert to symbol first, and nowhere was that covered. I am new to flash and could really use a few pointers.

    Reply to this comment

Leave a Reply