- Home
- Tutorials
- Flash
- Intermediate
- Creating a Simple Website

Brief Description
Hello again! Ok, to understand the code you should consider what happens when you click a button. Consider that following scenario:
From the "main" page, you press the "Images" button when the the "home" page is currently being viewed. Note that when the home page is visible, the "home" movie is stopped at frame16 on the "actions" layer for that movie. The same behaviour should be portrayed from the "images" and "about" page movies.
After you press the "images" button, the following code will be executed:
on (release)
{
//Will execute when you release the mouse button on the "images" button
if (_root.nextPage == undefined)
{
_root.nextPage = "image.swf";
_root.container.loadMovie("image.swf");
}
else if (_root.nextPage != "image.swf")
{
if (_root.container.midFrame >= _root.container._currentframe)
{
_root.nextPage = "image.swf";
_root.container.play();
}
}
}
This is what this code does: If the "images" button is pressed, check to see if the
"_root.nextPage" variable is defined, if not, initialise it with the string "image.swf" andload the movie "image.swf" in the "_root.container" movie clip which is initially empty. If "_root.nextPage" is denfined then the if "_root.nextPage" doesn't hold the name of the movie requesting to be load ("image.swf") in "_root.container" check to see if the current is not equal the midframe of the currently loaded movie. If the it is on the midFrame at which the movie is stopped, set the the nextPage variable to "image.swf" and player the rest of the movie currently loaded in the "_root.container" movie clip.Remember when we wrote code on the last frame (30) on each page movie? Well when frame thirty of the currently loaded movie is reached it will load the movie whos name is located in the "_root.nextPage" variable. In effect a page transition occurs.
For closure, the folling code is what is executed when the 30th frame of what ever movie is loaded in the "_root.container" movie clip:
_root.container.loadMovie(_root.nextPage);
Ok that is the end of this tutorial. I hope this was some help and you understood it.
You can also add different stuff to each movie page that gives it its own characteristics and such. But make sure that they have the commonalities explained above. That concludes this tutorial.
Click this link to see the completed work: Completed Website
Spread The Word
8 Responses to "Creating a Simple Website" 
|
said this on 04 Feb 2007 5:15:57 PM CST
i found it a little bit difficult to follow your step by step guide to "Creating a simple Website" because i think you sometimes used the wrong page-name?! but i persisted in trying to complete it anyway but what i got in the end wasnt what was supposed to happen i think, but then again maybe i did something wrong. so i wanted to see your end result to compare it with mine but i am unable to open the link: "Completed Website" unfortunately. Hopefully you'll find my comments useful. Regards Danielle
|
|
said this on 25 Feb 2007 2:46:23 PM CST
I also found it difficult to fallow you step be step.Then end result was error scripts (2)for on Release for button instances unable to find I beleive home_swf. If you could Email me the link would be great so i can see where my errors were
|
|
said this on 12 Mar 2007 7:13:55 AM CST
well i followed your tt but ditent work
im using flash pro 8 here is the error code **Error** Symbol=menu, layer=about, frame=1:Line 1: Mouse events are permitted only for button instances on (release) **Error** Symbol=menu, layer=Images, frame=1:Line 1: Mouse events are permitted only for button instances on (release) **Error** Symbol=menu, layer=Home, frame=1:Line 1: Mouse events are permitted only for button instances on (release) Total ActionScript Errors: 3 Reported Errors: 3 |
|
said this on 14 May 2007 4:41:26 PM CST
Hi Thomas, you probably have the wrong script in frame 1, layer "actions" of the "main.fla". It should simply be:
var nextPage = "home.swf"; container.loadMovie(nextPage); it seems you have some mouse action, probably from the buttons, there instead of the above code... |
|
said this on 05 Sep 2007 2:04:31 PM CST
fix the link so we can see what the finished product looks like
|
|
said this on 06 Sep 2007 11:06:47 AM CST
I got the same exact error as thomas. I copied and pasted your code exactly. Flash is having a problem with starting the action script for:
on (release) |
|
said this on 16 Oct 2007 1:36:23 PM CST
Can I do it using flash cs3?
Thanx |
|
said this on 30 Oct 2008 6:08:28 AM CST
I will try to explain what happend here and what do you need to work:
the Main.swf will call the home.swd automaticaly, In the Main.fla you need : the container ( x,y = o ), the buttons with the action script for each buttons: home - about us - contact - ( just cut in paste the script buttons from this tutorial ) and in the keyframe action insert this code: var nextPage = "home.swf"; container.loadMovie(nextPage); that it`s all for main.swf ! NOTE: the Main.swf have 3 things: container, keyframe with action script, buttons with action script for home.swf, aboutus.swf and contact.swf you need : on keyframe 1 var midFrame = 16; on keyframe 16 stop(); on keyframe 30 _root.container.loadMovie(_root.nextPage); it`s a great tutorial becouse work well and make your website smaller and without preloaders. |



Author/Admin)