Flash 8 :: Preloaders

Started by: KooKas-Kreations | Replies: 26 | Views: 8,261

KooKas-Kreations

Posts: 0
Joined: Aug 2025
Jan 21, 2008 9:34 PM #78931
In this tutorial, you'll learn how to make several kinds of preloaders, using getBytesLoaded(); and getBytesTotal(); - their purpose is self-explanatory; they get the amount of loaded and total bytes.
Now there aren't any pictures as of yet, but because its mainly code it shouldn't need them.

Bar Preloader

You've probably seen this one hundreds if not thousands of times, if you haven't you probably don't even know what Flash is and shouldn't really be reading this. This is quite simple - use the Rectangle tool to make a long bar. I suggest about 180 pixels wide by 15 pixels high. Place it well. Usually, they are in the centre (American: Center) of your stage. Position it how you like, though. Select it, press F8. Call it what you like, preferably something that make it obvious that it's a preloader. It needs to be a movie clip. Also, under Registration, the square is, by default, in the middle. Click on the square to the left of it, and then press OK or your Enter key. Now that's practically done. Click the newly created Movie Clip if it's not selected already and press F9. In it, enter this:

onClipEvent(load) {
var Percentage;
var BytesLoaded;
var BytesTotal;
}
onClipEvent(enterFrame) {
BytesLoaded = getBytesLoaded();
BytesTotal = getBytesTotal();
Percentage = BytesTotal/BytesLoaded*100;
_xscale = Percentage;
}
Congratulations. Now I know it's hard to test it out, but I assure you, it works.

Here's the stuff you should know:

getBytesLoaded(); - This gets the amount of bytes that have been loaded.
getBytesTotal(); - This gets the total amount of bytes to be loaded.
_xscale - This is the variable which treats size as a percentage.
onClipEvent() { } = (load) - When the movie clip with this code applied to is loaded, these actions are performed. (enterFrame) - Every frame of the movie these actions are performed. This is not the kind of frames in your timeline. If your frame-rate is 30 fps, then it performs these actions 30 times a second.

Informative Preloader

I'll teach you how to make a Percentage and Bytes Loaded/Bytes Total
preloader. Create two text boxes. Position them well. Give one an instance name of Bytes, and another of Percentage. And now for the code. Just put this on the first frame:

var BytesLoaded = getBytesLoaded();
var BytesTotal = getBytesTotal();
var Percentage = BytesTotal/BytesLoaded*100+"%";

Percentage.text = Percentage;
Bytes.text = BytesLoaded+"/"+BytesTotal;
Lets say I have a Flash of 1KB - That's 1024 bytes. When fully loaded,
the outputs (the text boxes) should look like this:
Bytes = 1024/1024
Percentage = 100%

Frame-By-Frame Preloader

This one can do pretty much anything you like as it loads. Create a new Movie Clip (name and registration don't matter) and inside it create 100 frames. On each frame draw what you want it to do. Each frame is 1%. When you're done, go on to the stage and put your preloader there, if it isn't there already. Click on it and press F9. Inside, type:

onClipEvent(load) {
var BytesLoaded;
var BytesTotal;
var Percentage;
}
onClipEvent(enterFrame) {
BytesLoaded = getBytesLoaded();
BytesTotal = getBytesTotal();
Percentage = BytesTotal/BytesLoaded*100;
gotoAndStop(Percentage);
}

Now it'll go to the frame correpsonding to the percentage. For example, it would go to frame 100 at 100%.

EDIT This is important! Don't forget to put:

if(Percentage == 100) { 
_root.play();
}


In your enterFrame events!

EDIT Important for the Imformative Preloader! The text boxes have to be big enough of course, so make the Percentage textbox big enough for 4 characters and the Bytes textbox as big as possible. By 'big' I mean wide, and don't use the transform tool, use the square/circle found in the top right of the textbox when you select it.
.::xmarkusx::.
2

Posts: 71
Joined: Feb 2007
Rep: 10

View Profile
Jan 21, 2008 10:00 PM #78935
Nice tutorial really helped me alot thanks dude, and Welcome to stickpage! ^^
KooKas-Kreations

Posts: 0
Joined: Aug 2025
Jan 21, 2008 10:08 PM #78936
Quote from .::xmarkusx::.
Nice tutorial really helped me alot thanks dude, and Welcome to stickpage! ^^

Thanks, glad it helped.
SSOutPhase
2

Posts: 454
Joined: Jun 2006
Rep: 10

View Profile
Jan 22, 2008 12:05 AM #78950
Although I'm real fimiliar with flash, I needed some help with preloaders. It'd also help if you had screenshots too. Thanks for the tut.
KooKas-Kreations

Posts: 0
Joined: Aug 2025
Jan 22, 2008 6:02 PM #79091
Okay, thanks for the feedback, I'll see what I can do.
boogerbag

Posts: 0
Joined: Aug 2025
Jan 24, 2008 11:29 PM #79576
awesome, now i finally know how to make a preloader
Rather Cheesy
2

Posts: 2,137
Joined: Apr 2007
Rep: 10

View Profile
Jan 27, 2008 8:41 PM #80313
Excellent tut, like the others said, add some screenshots. BUt other wise, very helpful.
Cobra42

Posts: 0
Joined: Aug 2025
Mar 1, 2008 6:45 AM #86521
god shit everytime i try to use a preloader tut, THE F*CKING CODE THINGS DONT WORK!!!1 *TWITCH*
zawmbee
2

Posts: 6,197
Joined: Jun 2007

View Profile
Mar 3, 2008 7:46 PM #87317
Then Maybe You Shouldnt Bump Old Threads *twitch*
Gavel
2

Posts: 6,675
Joined: Oct 2006
Rep: 10

View Profile
Mar 4, 2008 12:49 AM #87371
Quote from zombpiv
Then Maybe You Shouldnt Bump Old Threads *twitch*

That doesn't have anything to do with the actionscript code not working. That's a mistake on his part because he didn't follow the tutorial properly. And this thread isn't even that old. It was only made less than 2 months ago.

So shut up.
Killcycle
2

Posts: 80
Joined: Feb 2008
Rep: 10

View Profile
Mar 22, 2008 7:39 AM #97712
I am trying to use the bar style preloader in flash 8 and I did everything in the instructions however I do not get the last part..

EDIT This is important! Don't forget to put:

Code:

if(Percentage == 100) {
_root.play();
}

In your enterFrame events!

What is this telling me to do? What are the enterframe events..

I just want a preloader that will fully load the movie before someone plays it so that it runs smooth, because it's a big movie.
demon30
2

Posts: 153
Joined: Mar 2008
Rep: 10

View Profile
May 30, 2008 10:14 PM #144788
This is a Really cool tutorial but i think i'm too stupid to understand =( it doesn't work!!! i'll figure it out anyways =) i have to. And thanks a lot ^,,^ this tut WILL BE very helpful to me =)
Prince of PIMPs
2

Posts: 294
Joined: Dec 2007
Rep: 10

View Profile
May 31, 2008 9:06 PM #145353
does this also work with flash5.0?
Nikiyolstik

Posts: 0
Joined: Aug 2025
Jun 2, 2008 10:12 PM #147218
I don't understand. de info thing only shows 255/255.
The bar thing keeps full.
And the Frame-Frame, well i made it, But now what?!!!

I'm sorry my swf was too light
taconaf

Posts: 0
Joined: Aug 2025
Jun 10, 2008 10:25 AM #152911
it doesnt work for me ?