1. Home
  2. Computing & Technology
  3. Animation

Easiest Flash PreLoader Ever

By , About.com Guide

7 of 7

On the second frame, create a keyframe on any layer (it doesn’t matter which, just take one of the static held frames and convert it to a keyframe) and then right-click to open the Actions panel. First, insert another stop; what we’ll do is create a loop between frames one and two, with the scene stopping on frame two and never reaching frame three. We don’t want it to go to frame three until a certain condition is met: the main movie has downloaded completely. For that we’ll use the following script:

if (_root.getBytesLoaded( ) < _root.getBytesTotal( )) {
gotoAndPlay(1) ;
}
if (_root.getBytesLoaded( ) = = _root.getBytesTotal( )) {
gotoAndPlay(3) ;
}

What this is doing is telling Flash, when the second frame plays, to check how many bytes of the movie have downloaded (getbytesLoaded), and compare it to how many bytes are in the movie overall (getBytesTotal). If the amount loaded is less than the total, then Flash is to go back to frame one of the scene and keep playing, so that when it enters frame two again it’ll perform this test again until the proper conditions are met. If the amount loaded is the same as the total, though, then Flash is to go to and play frame three, where we’ve placed the start button.

Note the = = instead of =. In Flash, you must use two signs and not one for an arithmetic comparison.

Click here to view the preloader.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Easiest Flash PreLoader Ever

©2009 About.com, a part of The New York Times Company.

All rights reserved.