| |
The Flash Preloader The Flash preloader is usually the first scene that is seen while a
lengthy Flash movie is downloading from the Web. You may see a horizontal
bar increasing in length as the movie loads to show the progress graphically.
Additionally there is usually a percentage of movie loaded data shown
and fancy preloaders may even show number of bytes loaded, bytes remaining
as well as length of time remaining. The preloaders use Actionscript
to obtain the number of bytes loaded to be divided by total bytes of
the movie to calculate the percentage of movie loaded. Dynamic text
is used to display this data.
bytes_loaded = Math.round(_root.getBytesLoaded()); bytes_loaded is the variable is calculated from the getBytesLoaded commanded and of course bytes_loaded is derived from the getBytesTotal commanded. getPercent is the first variable divided by bytes_total. When multiplied by 100, one gets percentage. loadBar is the name of the movieclip which is the graphic, a horizontal bar which lengthens as the download progress. The _width function is what controls it's width as a function of the getPercent value. The greater the getPercent, the longer loadBar is. Note: when a movieclip is created such as the loadBar here, it's register must be set on the left. Otherwise it will be centered by default and the movieclip will increase in size from the middle, not the left. The second frame has the following Actionscript: gotoAndPlay(1); If bytes_loaded doesn't equal bytes_total, the preloader loops back to frame 1. Once those two equal, the action goes to frame 3 where a stop action holds things in place and a Play button can be pressed to play the movie, obviously! on (release) is the actionscript for the Play button. There are 2 preloader files available below. Both have loading bars and percentage readout. They're in Flash version 6 and are ready to use, but can be readily customized however one wishes. They're both Zipped. A little fancier one with more data displayed will be coming shortly.
For further study on preloaders get the book, "Teach Yourself Flash MX ActionScript in 24 Hours from Sams books from any good bookstore or Amazon.com. Some good material can be read at Flashkit.com as well. Enjoy! |