my_lv.onLoad = function(success:Boolean) {
loadvars_pb.setProgress(my_lv.getBytesLoaded(), my_lv.getBytesTotal());
delete timer_mc.onEnterFrame;
if (success) {
trace("LoadVars loaded successfully.");
} else {
trace("An error occurred while loading variables.");
}
};
my_lv.load("[place a valid URL pointing to a text file here]");
LoadVars.getBytesTotal()
Availability
Flash Player 6.
Usage
my_lv.getBytesTotal() : Number
Parameters
None.
Returns
An integer.
Description
Method; returns the total number of bytes downloaded by
LoadVars.sendAndLoad()
or if a load operation has not started. This method also returns
bytes can't be determined (for example, if the download was initiated but the server did not
transmit an HTTP content-length).
Example
The following example uses a ProgressBar instance and a LoadVars object to download a text file.
When you test the file, two things write to the log file: whether the file loads successfully and how
much data loads into the SWF file. You must replace the URL parameter of the
LoadVars.load()
attempt to use this example to load a local file that resides on your hard disk, this example will not
work properly because in test movie mode Flash Player loads local files in their entirety. To see this
code work, add a ProgressBar instance called
ActionScript:
var loadvars_pb:mx.controls.ProgressBar;
var my_lv:LoadVars = new LoadVars();
loadvars_pb.mode = "manual";
this.createEmptyMovieClip("timer_mc", 999);
timer_mc.onEnterFrame = function() {
var lvBytesLoaded:Number = my_lv.getBytesLoaded();
var lvBytesTotal:Number = my_lv.getBytesTotal();
if (lvBytesTotal != undefined) {
320
Chapter 6: ActionScript Core Classes
. This method returns
command so that the parameter refers to a valid text file using HTTP. If you
LoadVars.load()
if no load operation is in progress
undefined
undefined
to the Stage. Then add the following
loadvars_pb
or
if the number of total
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?