Accessibility

TechNote (Archived)

How to create movies that download before playing

Basic method

The basic method for preloading a movie is simple. One basic example is outlined below. Follow the provided step-by-step instructions to create your own preloading movie.

Basic method overview:
  • The movie being preloaded must contain at least two blank frames at the beginning of the movie, (frames 1 and 2).
  • The actual beginning of the main animation or presentation begins on frame 3.
  • On frame 1, an action tests if a later frame of the movie, (usually the last frame), has been loaded into the player.
  • If the test is FALSE, and the later frame has not yet been loaded, playback continues to the next frame (frame 2).
  • Frame 2 contains a goto action that returns the playback head to frame 1, where the test is performed again. This creates a loop between frames 1 and 2 until the later frame is loaded.
  • When the test in frame 1 returns a TRUE value (when the later frame is loaded), a Go To action sends the playback head to frame 3, where the main animation begins.

Note: This document explains how to set up movie to preload using Flash 5. For information on how to preload movies in earlier versions of Flash see Preloading movies in Flash 4 and earlier (TechNote 14673).

Steps to enable a movie to preload:
  1. Create two blank keyframes in frames 1 and 2 of the timeline. The actual animation should start at frame 3.
  2. Double-click frame 1 in the Timeline to open the frame Actions panel.

    Make sure that the Parameters pane on the lower portion of the Actions panel is visible. If it is not visible, click on the small white triangle on the lower-right side of the Actions panel to make expand the Parameters pane. See illustration below.
  3. In the Toolbox list on the left hand side of the Actions panel click on the category named 'Actions'.
  4. In the Actions category, locate the action named 'If'. Double-click on it to insert the action. The following dialog box appears:
  5. In the Condition field type the following:

    _framesLoaded ==_totalframes

    This If statement checks to see if the last frame that was loaded into the Flash player is the same as the total number of frames contained in the movie file. _framesLoaded and _totalframes are both built in properties of every Flash movie and movie clip that indicate, respectively, the last frame loaded into the Flash player and the total number of frames in the movie.

    You can also specify the frame number instead of using the _totalframes property. Use this method when only a certain number of frames needs to be preloaded instead of the entire movie.

    The equality operator "==" is used here. The assignment operator"=" is used to assign a value to a variable, not to compare values. For a thorough explanation of equality and assignment operators, please refer to page 56 of the Flash 5 ActionScript Reference Guide.

    Note: The ifFrameLoaded action has been deprecated in Flash 5. (This is the reason it appears with a green background in the Actions panel.) Use of the _framesLoaded property as demonstrated in this TechNote is the preferred method for checking if a movie has loaded.
  6. In the Actions category of the Toolbox list, double-click the 'goto' action to insert it. Enter "3" in the frame field, as illustrated below.

    This ultimately sends the playback head to frame 3, where the main animation begins.
  7. Leaving the actions window open, select frame 2 in the Timeline.
  8. Choose the Actions category of the Toolbox list and insert a 'goto' action. Use the default parameters for the goto action that appear in the parameters pane, leaving frame 1 as the chosen frame number.

    This returns the playback head to frame 1, creating a loop, if the frame after is not yet loaded.
Testing the method

If the file resides on the local machine, the file is already completely loaded, and beginning frames will not be seen on playback. To test the performance, use the Bandwidth Profiler and Show Streaming features of Flash, available under "View" in Test Movie mode. Choose the estimated download speed from the Debug menu. More information on using the Bandwidth Profiler is available on page 315 of the Using Flash manual.

Displaying a "preload animation"

Often, while a movie is preloading, a short animation or static graphic is shown inform the user of what is happening. The following steps explain how to accomplish this in accordance with the steps outlined above.

To display an animation while preloading, follow the steps below:
  1. Create a new movie clip symbol that contains the animation to display while preloading.
  2. Insert a new layer in the timeline. Drag an instance of the movie clip created in step 1 onto the stage.
  3. Insert a blank keyframe in frame 3 of that layer. This ensures that the animation will only be visible while the playback head loops between frames 1 and 2 (that is, while the movie is preloading).


AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:tn_12588
Browser:Chrome
Internet Explorer
Netscape
Opera
Safari
Firefox
Database:DB2
Informix
MySQL
Oracle
SQL Server
Sybase
MS Access

Products Affected:

flashplayer