Getbytesloaded (Loadvars.getbytesloaded Method) - MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

See also
onData (LoadVars.onData handler)
getBytesLoaded (LoadVars.getBytesLoaded
method)
public getBytesLoaded() : Number
Returns the number of bytes downloaded by
LoadVars.sendAndLoad()
progress or if a load operation has not yet begun.
Availability: ActionScript 1.0; Flash Lite 2.0
Returns
- An integer.
Number
Example
The following example uses a ProgressBar instance and a LoadVars object to download a text
file. When you test the file, two things are displayed in the Output panel: whether the file
loads successfully and how much data loads into the SWF file. You must replace the URL
parameter of the
LoadVars.load()
using HTTP. If you 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
the Stage. Then add the following ActionScript to Frame 1 of the Timeline:
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) {
trace("Loaded "+lvBytesLoaded+" of "+lvBytesTotal+" bytes.");
loadvars_pb.setProgress(lvBytesLoaded, lvBytesTotal);
}
};
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 {
,
parseXML (XML.parseXML method)
LoadVars.load()
. This method returns
command so that the parameter refers to a valid text file
or
if no load operation is in
undefined
to
loadvars_pb
LoadVars
395

Advertisement

Table of Contents
loading

Table of Contents