03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Returns<br />

Number - An integer.<br />

Example<br />

The following example uses a ProgressBar instance <strong>and</strong> a LoadVars object to download a text<br />

file. When you test the file, two things are displayed in the Output panel: whether the file<br />

loads successfully <strong>and</strong> how much data loads into the SWF file. You must replace the URL<br />

parameter of the LoadVars.load() comm<strong>and</strong> so that the parameter refers to a valid text file<br />

using HTTP. If you attempt to use this example to load a local file that resides on your hard<br />

disk, this example will not work properly because in test movie mode Flash Player loads local<br />

files in their entirety. To see this code work, add a ProgressBar instance called loadvars_pb to<br />

the Stage. Then add the following ActionScript to Frame 1 of the Timeline:<br />

var loadvars_pb:mx.controls.ProgressBar;<br />

var my_lv:LoadVars = new LoadVars();<br />

loadvars_pb.mode = "manual";<br />

this.createEmptyMovieClip("timer_mc", 999);<br />

timer_mc.onEnterFrame = function() {<br />

var lvBytesLoaded:Number = my_lv.getBytesLoaded();<br />

var lvBytesTotal:Number = my_lv.getBytesTotal();<br />

if (lvBytesTotal != undefined) {<br />

trace("Loaded "+lvBytesLoaded+" of "+lvBytesTotal+" bytes.");<br />

loadvars_pb.setProgress(lvBytesLoaded, lvBytesTotal);<br />

}<br />

};<br />

my_lv.onLoad = function(success:Boolean) {<br />

loadvars_pb.setProgress(my_lv.getBytesLoaded(), my_lv.getBytesTotal());<br />

delete timer_mc.onEnterFrame;<br />

if (success) {<br />

trace("LoadVars loaded successfully.");<br />

} else {<br />

trace("An error occurred while loading variables.");<br />

}<br />

};<br />

my_lv.load("[place a valid URL pointing to a text file here]");<br />

See also<br />

load (LoadVars.load method), sendAndLoad (LoadVars.sendAndLoad method)<br />

load (LoadVars.load method)<br />

public load(url:String) : Boolean<br />

368 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!