MovieClip.getBytesTotal( ) Method | Flash 5 |
check the size of a clip or movie, in bytes |
An integer representing the uncompressed size of mc, in bytes. Divide by 1024 to convert bytes to kilobytes (KB).
The getBytesTotal( ) method tells us the uncompressed size, in bytes, of a clip instance or the main movie. When invoked on the main movie, getBytesTotal( ) reports the size of the entire .swf file. It is normally used in concert with getBytesLoaded( ) to create preloaders for main movies and .swf or .jpg files loaded into instances or levels via loadMovie( ).
The loadMovie( ) and unloadMovie( ) functions are executed asynchronously. Hence, the return value of getBytesTotal( ) varies according to when it is called and the value of mc, as follows:
If mc is undefined, getBytesTotal( ) returns undefined.
After a loadMovie( ) or unloadMovie( ) statement occurs in source code, but before it executes, and before the size of the external file has been determined, getBytesTotal( ) returns the size of the existing content in mc (prior to the loadMovie( ) or unloadMovie( ) statement). An empty movie clip created manually during authoring has a byte size of 4. An empty movie clip created via MovieClip.createEmptyMovieClip( ) has a byte size of 0.
Once the file size is determined, getBytesTotal( ) returns the complete size of mc, unless the file at url is not found.
If the file at url is not found, getBytesTotal( ) returns -1 (even if mc is a document _level that did not previously exist) and getBytesLoaded( ) returns 0.
After an unloadMovie( ) command executes, getBytesTotal( ) returns 0 if mc is a movie clip or undefined if mc is a document level, such as _level0. The same applies to getBytesLoaded( ).
As with getBytesLoaded( ), in Flash 6 the return of getBytesTotal( ) reflects the uncompressed size of the .swf file being loaded, not the size of the file after Flash compression has been applied. This means that getBytesTotal( ) for a .swf file with a post-compression size of 2,000 bytes might return, say, 10,000 bytes. As such, it cannot be used to predict the time left in the download of a compressed .swf file. It is intended to offer only a relative measure of the percentage of the file that is downloaded, in concert with getBytesLoaded( ).
loadMovie( ), MovieClip._framesloaded, MovieClip.getBytesLoaded( ), MovieClip.loadMovie( ), MovieClip._totalframes, MovieClip.unloadMovie( ), unloadMovie( )