Pre-loader  

 

Open up flash, if you have Flash CS3, make a ActionScript 2.0 Flash File, if not just make a new Flash file.

You can make your game as big as you want on the properties tab at the bottom.  I have mine as the default 550x400 but you can make it as big or small as you want.

 

For the pre-loader we are just going to make a basic pre-loader that shows the percent done.  If you want a better one, there are TONS of tutorials on the internet on how to make a flash pre-loader.

 

To stop cluttering make a new folder on the layer screen at the top. Name that folder Pre-loader (or whatever you want to name it) so you can go back to it easily later.  Within that folder, make a new layer and call it graphics (or whatever you want to name it)

 

 

In the graphics layer, make a static text, that says “Loading” (or whatever you want) and put it somewhere on the screen.    

Now, the hard part! Create another text but this time, make it a dynamic text.  But where it says Var: type “percent_mc” so that it will animate to show how much of the game is loaded! 

 

Now make another layer within the folder “Pre-Loader” and call it code. 

 

Press F9 or go Window -> Actions.

Then copy and paste this code into the window that opens up in Flash.

Make sure the top right says Actions – Frame, or else it wont work!

 

 

 

stop();

onLoad = function() {

total = _root.getBytesTotal();

}

onEnterFrame = function() {

 

loaded = _root.getBytesLoaded();

percent = int(loaded/total*100);

percent_mc = ""+percent+"%";

if (loaded == total) {

_root.gotoAndStop(2);

}

}

 

 

Now  it’s time to explain the code! 

 

Stop(); stops the animation, so it doesn’t automatically go to the next frame.

 

OnLoad = function(){ means when the frame loads, it starts whatever is in the brackets.

 

Total = _root.getBytesLoaded(); means the variable total, which is called upon later, is equal to the amount of bytes the whole game is.

 

OnEnterFrame = function(){ is almost the same as Onload, but every time it loads the frame, which is the frame rate that you can set in the properties tab.

 

Loaded = _root.getBytesLoaded(); is how much the game has loaded so far.

 

Percent = int(loaded/total*100);  means the variable percent is the total bytes, divided by the amount loaded, times 100.

 

Percent_mc = ""+percent+"%"; means that the dynamic text percent_mc is the percent of the game loaded, with a % at the end.

 

if (loaded == total) { just means that if the amount loaded, is the total, you do whatever is in the brackets.

 

_root.gotoAndStop(2);  means that you go to the next frame…we will explain more on this next tutorial.

 

 

If you want to see it, by pressing CTRL ENTER nothing happens. That is because it isn’t loading anything! You will have to wait for the next tutorial to see what it loads!

And that’s it for this portion of the tutorial!  I will be adding another part on the menu, and moving later. 
 

Thanks for reading!

 

 

By: Nerdsrule

         

 Copyright Zombie Eyed Gaming 2007-2008 ALL RIGHTS RESERVED