Stick Page Forums Archive

Lex0r's Preloader Tutorial [Flash][Actionscript]

Started by: V.Valentine | Replies: 44 | Views: 17,398

V.Valentine
2

Posts: 1,144
Joined: Aug 2005
Rep: 10

View Profile
Aug 27, 2005 10:21 PM #193
Got permission from Jay that i could post lex0r's preloader tute in a .doc format.

Please do NOT credit me on that or complain to me about what went wrong.

although credit does go to FrAnKeH for searching for it within the google cache.

just dl the file, open it, and read the contents.

Edit: And a heap load of credit to lex0r for taking time to do this.
Edit2: Due to people not having Microsoft i have decided to copy the instructions onto this post.

"This is something that alot of people struggle with so i decided to make this tutorial on how to create your very own preloader.


First off you will need to open flash, so open it.
On the layer that you have rename it:
loadBar

Use the rectangle tool and create a little bar, the legnth you want your loading bar to be.
Making sure that there is NO outline on your bar.
Now select your bar and press F8 to open up the convert to symbol box.
Call it loadBar and make sure that the type of symbol is a 'Movie Clip'
Then set its registration point to the left hand side.

It should look exactly like this:
Image

Then single click on your new Movie Clip and go into the properties panel. If you can't see your properties panel (at the bottom press Ctrl+F3)
And give the instance a name of loadBar, like this:
Image

Once that is done create another layout and call it border. Make sure that this new layer (border) is above the loadBar layer.
Then draw around the bar in the new layer with whatever colour you want.

Now we'll leave the loading bar alone for a bit and get started on the percentage text.

Create a new layer and call it loadText, make sure that this layer is above both border and loadBar layers.
Create a text box in the new layer (loadText) and make sure its a Dynamic Text Box, look at this next pic to see how to set this:
Image

Then give it a Variable Name of loadText like this:
Image

That is the whole drawing side of the perloader done. Now we'll get to the most trickiest part the programming, which infact isn't as hard as everyone thinks.

Create a new layer and call this layer actions. Then create two new keyframes on the actions layer so there are 3 key frames in all.
Make sure that the other 3 layers span two of them keyframes.
This sounds confusing so heres a screen shot of what I mean:
Image

Now right click on frame ONE of the the actions layer and select actions, this should make a little box at the bottom of the page appear.
Copy this code into the actions:

bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
this.gotoAndPlay(3);
}


Now right click on frame TWO of the actions layer and put this in the actions box:

this.gotoAndPlay(1);


Then right clcik on frame THREE of the actions layer and put this in the actions box:

stop();


And thats it. Your preloader should now work.
I would go through the code with you, but since its more a thing of copy paste, there is not much point.
If you would like to know what the code means, just let me know and I'll tell you.

Hope it helps people

UPDATE

some people are saying that there loading bar isn't reaching the end of there rectangle well what you need to do is in the code


bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
this.gotoAndPlay(3);
}


the part- this.loadBar._width = getPercent*100;
the 100 is the width of your loading bar at its full legnth, for example if you r loading bar is 200 px wide then you cahnge it to
this.loadBar._width = getPercent*200;

I hope that clears that up


Next update to this first update :)

DA asked me how to make it display the Bytes loaded, well create another layer can call it loadBytes.
Draw another dynamic text box and give it a Variable name of loadBtyes just like the loadText one.

Then in the programming add


this.loadBytes = bytes_loaded+"Bytes";


so your new code should look like this


bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+"%";
this.loadBytes = bytes_loaded+"Bytes";
if (bytes_loaded == bytes_total) {
this.gotoAndPlay(3);
}


There you have it, that now displays the bytes loaded, a loading bar, and a percent loader."

By Lex0r. And here's the .doc file you can dl. It'll soon change into .txt when i have time.
Uplined

Posts: 0
Joined: Jun 2025
Mar 6, 2006 8:11 AM #5408
Ty i was looking for that tut for ages since the forum came down ;)
kingsecho
2

Posts: 14
Joined: Feb 2006
Rep: 10

View Profile
Mar 8, 2006 6:18 PM #5484
It comes up with an error, i dont have microsoft word!!!!!!!!!
V.Valentine
2

Posts: 1,144
Joined: Aug 2005
Rep: 10

View Profile
Mar 8, 2006 7:07 PM #5485
Quote from kingsecho
It comes up with an error, i dont have microsoft word!!!!!!!!!

Seriously, every computer should have that, along with Excel, Powerpoint, and other stuff.

What the hell do you do with your H/w without it?
Apart from pen and paper...
52xM
2

Posts: 647
Joined: Sep 2005
Rep: 13

View Profile
Mar 8, 2006 7:20 PM #5486
NOTEPAD!!! Bwhahaaahaaaaa!

i'm gonna rate it when i've read it...

EDIT: I think it was alright, well explained. Even though i don't do anything with Flash, so i'm not sure if it's all right.
A lack of pictures is a problem if someone doesen't know anything, but it think they'll get the idea eventually.

so 8/10

yes i'm the wrong person to rate this, but who cares....
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Mar 9, 2006 5:29 AM #5499
Quote from Uplined
Ty i was looking for that tut for ages since the forum came down ;)


Does anyone realise how big a bump that was? It was like, a year or something... I mean... WTH?
kingsecho
2

Posts: 14
Joined: Feb 2006
Rep: 10

View Profile
Mar 9, 2006 4:28 PM #5503
does anybody know were i can get word, from like the internet or such. and i dont do my homework, i cant be bothered.
Mantiscore
2

Posts: 638
Joined: Aug 2005
Rep: 26

View Profile
Mar 9, 2006 4:35 PM #5504
Quote from The Scarecrow
Does anyone realise how big a bump that was? It was like, a year or something... I mean... WTH?


Are you uneducated?

You are allowed to bump tutorials, otherwise youd have to make exactly the same thread again to ask questions, compliment and such.

Fuh.
V.Valentine
2

Posts: 1,144
Joined: Aug 2005
Rep: 10

View Profile
Mar 9, 2006 9:09 PM #5516
Quote from Mantiscore
Are you uneducated?

You are allowed to bump tutorials, otherwise youd have to make exactly the same thread again to ask questions, compliment and such.

Fuh.

I <3 You.
It's lacking pictures because lex0r had deleted those from his photobucket account.
Mantiscore
2

Posts: 638
Joined: Aug 2005
Rep: 26

View Profile
Mar 9, 2006 10:15 PM #5519
Aw, i <3 you too.
Ordinair
2

Posts: 298
Joined: Aug 2005
Rep: 129

View Profile
Mar 9, 2006 11:05 PM #5520
Well since this topic was already bumped, posting wont be a big deal;

I dont have microsoft word. >_> I know. Its crazy, but I dont. I have "Word Perfect". Care to attach a txt file or any other universal form of text?
V.Valentine
2

Posts: 1,144
Joined: Aug 2005
Rep: 10

View Profile
Mar 10, 2006 8:00 AM #5530
Quote from strong2
Well since this topic was already bumped, posting wont be a big deal;

I dont have microsoft word. >_> I know. Its crazy, but I dont. I have "Word Perfect". Care to attach a txt file or any other universal form of text?

That or i'll edit the 1st post with the actual instructions.
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Mar 10, 2006 11:23 PM #5600
Quote from Mantiscore
Are you uneducated?

You are allowed to bump tutorials, otherwise youd have to make exactly the same thread again to ask questions, compliment and such.

Fuh.


No, not uneducated, just unaware of that fact. I'll take note of that for next time.
stick-fu_man

Posts: 0
Joined: Jun 2025
Mar 11, 2006 1:08 AM #5610
EEEHA!!!! That's exactly what I wanted!!! Thanks!
kingsecho
2

Posts: 14
Joined: Feb 2006
Rep: 10

View Profile
Mar 17, 2006 9:18 PM #5930
Do i now start the animation and put the play button and such in frame 3?
Website Version: 1.0.4
© 2025 Max Games. All rights reserved.