Creating Interactive Movies > Using basic actions for navigation and interaction > Checking whether a frame is loaded

Checking whether a frame is loaded

To create a preloader to prevent certain actions from being triggered before the needed content has been downloaded by the viewer, use the If Frame Is Loaded action. A preloader is a simple animation that plays as the rest of a movie downloads. The If Frame Is Loaded action is helpful for verifying that a large file (such as a bitmap or sound) is loaded. You can also use the _framesloaded property (within an If action) to check whether the contents of a specific frame are available locally.

Using either the action or the property, you can start playing a simple animation while the rest of the movie downloads to a local computer. Both check whether the contents of a specific frame are available locally.

Typically, the If Frame Is Loaded action is used as a frame action, but it can also be used as a button action. To test an If Frame Is Loaded condition, use the Streaming option with the Test Movie command. The frames load as if streaming from a Web site. For more information, see Testing movie download performance.

To check whether a frame has been loaded:

1 Select the frame, button instance, or movie clip instance to which you will assign the action.
2 Choose Window > Actions to display the Actions panel.
3 In the Toolbox list, click the Basic Actions category to display the basic actions, and select the If Frame Is Loaded action.
4 In the Parameters pane, for Scene, select the scene containing the desired frame: Current Scene or a named scene.
5 For Type, choose Frame Number, Frame Label, or Expression.
6 For Frame, specify the frame to be loaded before the action is triggered as a frame number, frame label, or expression, according to your selection in step 5.
7 Select the action to occur when the particular frame has been loaded.
Flash enters ActionScript similar to the following in the Actions list:
ifFrameLoaded (100) {
        gotoAndPlay (10);
}

To use the If Frame Is Loaded action to play a short animation as a movie loads:

1 Create a short animation loop at the beginning of the movie. For example, you can create a loop that displays the message "Movie loading ..."
2 Create a frame action with the If Frame Is Loaded action that jumps out of the animation loop when all the frames are loaded and continues playing the movie.
For example, a 30-frame movie that has a 2-frame animation loop at the beginning requires the following action attached to Frame 1:
ifFrameLoaded (30) {
		gotoAndPlay (3);
To complete the example, attach the following action to Frame 2, to restart the movie at Frame 1:
gotoAndPlay (1);
When the frame specified in the If Frame Is Loaded action loads, the movie skips the second frame and continues playing the movie from the third frame.

To use the _framesloaded property in an action to play a short animation loop as a movie loads:

1 Create a short animation loop at the beginning of the movie. For example, you can create a loop that displays the message "Movie loading ..."
2 Create a frame action that jumps out of the animation loop after all the frames are loaded and continues playing the movie.
For example, a movie that has a two-frame animation loop at the beginning requires the following action attached to Frame 2:
if(_framesloaded==100) {
	gotoAndPlay (3); 
} else {
	gotoAndPlay (1);
} 

For more information on the _framesloaded property, see ActionScript Help.