Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create an advanced PRELOADER

Step-by-step tutorial

Create an advanced PRELOADER

by  davdesign  Posted    (Edited  )
[color green]Just to let you know that I'm relocating my server as of today, and for a period of three to four weeks, none of the links to my files on this site will work.

If you need a file from me which is linked from this site then please just email me details of the relevant link and I will send the relevant file(s) to you.

After I've relocated the server and all the files within it I shall endeavour to update all links in Tek-Tips.[/color]



I've just submitted this post for DorXBasS in the forum and thought I might as well set it up here, as there doesn't seem to be any:

the demo of this can be found at:
www.pinkzeppelin.com/FAQ/250-532/preloader.html

the fla can be found at:
www.pinkzeppelin.com/FAQ/250-532//preloader.zip


OK: What I mentioned in the forum was that you should paste the frames of your movie to start at the "site" label in the example I've made. The following actions are within the controller movie-clip:

[color red]
/:loaded = _root.getBytesLoaded();
[color green]1​
[/color]

/:total = _root.getBytesTotal();
[color green]2​
[/color]

if (Number (/:loaded) == Number (/:total)) {
[color green]3​
[/color]

tellTarget ("_root") {
gotoAndStop ("site");
}
}

/:percentage2 = (Math.floor(/:loaded /1000))+"K of "+(Math.floor(/:total / 1000))+"K loaded";
[color green]4​
[/color]

setProperty ("_root.bar", _xscale, number((/:loaded) / (/:total)) *100);
[color green]5​
[/color]

setProperty ("_root.bar", _y, "50");
[color green]6​
[/color]

[/color]

1>>>finds out the number of bytes loaded in the movie so far and assigns the variable '/:loaded' to that value. (note: the presence of "/:" before a variable name means that it is sending this variable to the main timeline)

2>>>finds the toal byte-size of the movie and assigns the variable '/:total' to that value.

3>>>This is the part that tells the maintimeline ("_root") to go to the frame "site" (ie: where I said you should make the starting point of the rest of your movie) when the two aforementioned variables are equal (ie: when your movie is fully loaded)

4>>>This line defines the variable "/:percentage2" which is the variable assigned to the dynamic textbox on the main stage. The actionscript "Math.floor" basically rounds the number down to the nearest integer. I guess you'll be able to figure out the rest of this line for yourself, pretty easy stuff.

5>>>Sets the scale of the loader bar. The loader bar is a movie-clip with instance name "bar" hence "_root.bar" .(If someone reading this has used flash 4 but not 5 too much, then _root is the equivalent of _level0 in flash4, adn basically defines the main timeline.). So this line is basically telling the loader bar to stretch to the defined percentage loaded (which takes the form of the equation (loaded/total)*100 .

6>>>Final line. If you've dragged your loader bar onto the main stage and tested the movie, you'll notice that you get a flicker, where the bar starts at 100% then drops to 0% when the scripting kicks in. In order to prevent this, I drag the bar off the main stage to where it can't be seen in the final movie. This action repositions the loader bar, and because it is the final action, it ensures that no flicker occurs.

There are three objects on the main stage: the loader mc; the control mc (which contains the above actions which loop until the main timeline is sent to "sent"); and the dynamic text box which displays the calculated amount loaded (in K-bytes) against the total movie-Kbyte-size.

I hope that explains everything.

dave
(phew)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top