How to Add a Preloader
A Flash preloader indicates the loading progress of a Flash film, and is a necessary part of each Flash movie as it prevents the movie from playing before it completely loads onto your computer. The preloader usually looks attractive to keep you occupied while the film is loading in the background, and also gives you an idea as to how long it will take before the movie loads onto your computer and starts playing.
Instructions
-
-
1
Click “Start,” “All Programs” and “Adobe Flash” to enter the Flash development interface. Double-click the layer on the time line and rename it “Preload.” Click the “Insert Layer” button to create another layer. Rename this layer “Actions.”
-
2
Click the "Preload" layer to start adding content to it. Click the Rectangle tool. Set the “Pen” color to black and the “Fill” color to blue. The preloader will be filled with blue to indicate the loading progress. Draw the preloader bar.
-
-
3
Click the Select tool to select the bar outline. Press “F8” to convert it to a symbol. Select “Movie clip” type and enter the name “Outline” for the symbol. Convert the body of the bar to a symbol "Progress bar.” Set the “Registration Point” of the symbol to the left side.
-
4
Select your bar and click “Properties.” Enter an instance name for the progress bar, such as “bar_mc.”
-
5
Double-click the "ActionScript" layer and input:
stop();
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{ }The loading function keeps checking if the load has finished or not via the event listener.
-
6
Add the following code to the loading function:
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
bar_mc.scaleX = loaded/total;The loading function will calculate the loaded data and the total data, and will work out the load percentage.
-
7
Add the following to the loading function to play the movie when it is fully loaded:
if (total == loaded){ play(); }
-
1
References
- Photo Credit Photos.com/Photos.com/Getty Images