Name

MovieClip._framesloaded Property — the number of frames of a clip or movie that have downloaded to the Player

Availability

Flash 4 and later

Synopsis

mc._framesloaded

Access

Read-only

Description

The integer _framesloaded property indicates how many frames of mc have been loaded into the Player (from to mc ._totalframes). It is normally used to create preloaders that pause playback until a sufficient number of frames have downloaded. For a movie clip, the _framesloaded property always equals _totalframes (because clips are loaded in their entirety before playing) unless the instance is in the process of loading an external .swf file due to a loadMovie( ) invocation. The _framesloaded property is, therefore, useful only with main movies or external .swf files loading into instances or levels.

Preloader code is traditionally placed directly on the main timeline of the movie being preloaded. A simple approach is to loop between frames 1 and 2 until the movie has loaded, at which point we go to the movie’s start frame. For example:

                     
// CODE ON FRAME 1
if (_framesloaded > 0 && _framesloaded == _totalframes) {
  gotoAndPlay("beginMovie");
}

// CODE ON FRAME 2
gotoAndPlay(1);

In Flash 5 and later, we may alternatively use the enterFrame movie clip event handler to build a more portable preloader. In the movie we wish to preload, at the frame where we want preloading to start, we invoke the stop( ) function. Then we place a movie clip with the following code on that movie’s timeline:

onClipEvent ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.