Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

 

 

 

 

 

 
Creating
a Preloader in One Frame

Ask any user what one of the most difficult Flash technique to master is. Many will say the Preloader. In Flash 4, pre-loaders were difficult to coordinate. You had to specify the loaded frame, a loop frame, and more! In Flash 5, all it takes is one frame with a few lines of code to create a preloader.

Here is how:

  1. Create a new movie. Right click the first frame and select Actions from the menu that appears.
     
  2. The Frame Actions window will appear. Press Ctrl + E to access the Expert Mode. From the Expert mode, you will be able to copy, paste, and input code directly without having to use the drop-down menus.
     
  3. Copy the code from the menu box below. Once the code below has been copied, paste it in the Frame Actions window.
     

  1. You may add a loading movie or something to engage the visitor in Frame 1. Make sure you do not go beyond Frame 1 for the loading animation. Use a movie clip (Insert | New Symbol) to make a complex animation fit in one keyframe. The following image is an example of how the timeline for an animation would look:

[ Notice that the First frame is void of content except for the loading movie clip on the 'action' layer. ]
 

Why the Animation Worked
Because you copied and pasted the code, I will explain why the code worked so you can understand
the code and use it in your own animations with full understanding.


if (_framesloaded>=_totalframes) {

This is by far the most important line of code in the pre-loader. An if statement is being started with the condition that the number of frames currently loaded in Flash ( _framesloaded) equals the total number of frames in the animation ( _totalframes).


if (_framesloaded>=_totalframes) {
        gotoAndPlay (2);
} else {
        gotoAndPlay (1);
}

 

This section of code holds the statements for making the if statement produce results. If the frames are loaded from the previous section of code, you are telling Flash to play the 2nd frame (gotoAndPlay 2). If all of the frames have not yet loaded, the section of code under the 'else' executes. The gotoAndPlay (1) line is a loop that continuously loops itself until all the frames have loaded.


Instant Replay: Animation Walkthrough
When the movie first loads, the first frame contains the actions for the pre-loader. Flash checks to see if all the frames have been loaded. That is the line with the _framesloaded and _totalframes. If the frames have all been loaded, Flash begins to play the animation at Frame 2. If the frames have not loaded, Flash re-plays the first frame containing the pre-loader action.

Tutorials related to this topic are:

 

I hope the information helped. If you have any questions or comments, please don't hesitate to post them on the kirupa.com Forums. Just post your question and I, or our friendly forum helpers, will help answer it.

The following is a list of related tutorial and help resources that you may find useful:

How to use the Forums
New, Upcoming, and In-Progress Tutorials
How to Help out kirupa.com
Writing Tutorials
 
Cheers!
Kirupa Chinnathambi
kirupaBlog

 

 


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components
flash menus, buttons and components Digicrafts Components
The best flash components ever! Entheos Flash Website Templates
Buy and sell FLAs at Ultrashock! Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Purchase & Download Flash Components flash components
Learn how to advertise on kirupa.com