View comments | RSS feed

MovieClip.getBytesTotal()

Availability

Flash Player 5.

Usage

my_mc.getBytesTotal() : Number

Parameters

None.

Returns

An integer indicating the total size, in bytes, of my_mc.

Description

Method; returns the size, in bytes, of the movie clip specified by my_mc. For movie clips that are external (the root SWF file or a movie clip that is being loaded into a target or a level), the return value is the size of the SWF file.

You can extend the methods and event handlers of the MovieClip class by creating a subclass. For more information, see "Assigning a class to a movie clip symbol" in Using ActionScript in Flash.

Example

The following example uses the _framesloaded property to start a SWF file when all the frames are loaded. If all the frames aren't loaded, the _xscale property of the movie clip instance loader is increased proportionally to create a progress bar.

Enter the following ActionScript in Frame 1 of the Timeline:

var pctLoaded:Number = Math.round(this.getBytesLoaded()/this.getBytesTotal()*100);
bar_mc._xscale = pctLoaded;

Add the following code to Frame 2:

if (this._framesloaded<this._totalframes) {
   this.gotoAndPlay(1);
} else {
   this.gotoAndStop(3);
}

Place your content on or after Frame 3. Then add the following code to Frame 3:

stop();

See also

MovieClip.getBytesLoaded()

Comments


Sardok said on Dec 9, 2004 at 2:19 AM :
I have used this command several times for various pre-loaders. Recently I discovered that sometimes the value of _root.getBytesTotal() exceeds the total file size of the SWF.

In a discussion forum I read that the value that is returned by _root.getBytesTotal() is the total size counting all images as uncompressed.

Is this statement true? If it is, could you please add a comment to your help files or on the LiveDocs.

Thanks!

Cheers,
Thobias Sjökvist
Venkman said on Mar 8, 2005 at 9:55 PM :
I have found this also. I tried testing it by unchecking the "compress
movie" option in my publish settings and it was spot on- a movie that was
only 152k while compressed became 349k uncompressed, and wouldn't
you know it- _root.getBytesTotal was telling me that all along.

Pretty annoying. I wish it would just display the size of the file the user is
downloading, not what flash decompresses it to be.
mspres said on Mar 10, 2005 at 8:24 PM :
Returns the uncompressed size! This is unacceptable. Did someone drop the ball? Do we have to wait for 8-ball for a fix? I'm not trying to be rude, but come on Macromedia. Stuff like this REALLY cost developers a LOT of time trying to work-around and figure out what the heck is going on. I'd like to request that 1) Every now and then take a look at the live doc comments. Just make this someone's full-time job, to peruse the live doc feedback, and relay information to editors and engineers to get things fixed and documentation corrected QUICKLY. 2) Be honest. You guys know way ahead of time when things don't work quite right, or the documentation isn't completely descriptive about conditions that impact usage. 3) Here's a real easy one... below the See Also section, create a new section for Technotes. Apparently, Flash Technotes are not currently associated with the documentation. It would be a fairly easy task to automate associations between the two, and it would save your customers lots of time and though we might not be happy to find that you've got an unfixed bug/odd behavior/[whatever political correct term you wish]; I personally would be less irritated having found the information sooner than later.
Francis Cheng said on Mar 10, 2005 at 10:54 PM :
Yes, we, the documentation team, dropped the ball on this one. The fact that getBytesTotal() returns the uncompressed size is by design. This absolutely should have been clearly documented. I sincerely apologize for the inconvenience this has caused you. I will file a documentation bug to make sure that this entry includes that information.
kinx said on Jun 7, 2005 at 7:24 AM :
This doesnt seem to work when dynamically loading a jpg into a movie clip
eg holder.loadMovie(image2load)

if you then try and find the total bytes
eg bytesTot = holder.getBytesTotal()/1024;

to build a preloader it doesnt return the value untill the image fully loads. Is there some setting I am missing on my server that is stopping this, or am I doing something wrong?
No screen name said on Sep 16, 2005 at 7:57 AM :
is there any work around to show the real file size?
I am making a flash of 5Mb and dont want someone loading it without knowing how much hes loading.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001504.html