03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

getBytesLoaded (XML.getBytesLoaded method)<br />

public getBytesLoaded() : Number<br />

Returns the number of bytes loaded (streamed) for the XML document. You can compare the<br />

value of getBytesLoaded() with the value of getBytesTotal() to determine what<br />

percentage of an XML document has loaded.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6<br />

Returns<br />

Number - An integer that indicates the number of bytes loaded.<br />

Example<br />

The following example shows how to use the XML.getBytesLoaded() method with the<br />

XML.getBytesTotal() method to trace the progress of an XML.load() comm<strong>and</strong>. You must<br />

replace the URL parameter of the XML.load() comm<strong>and</strong> so that the parameter refers to a<br />

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

on your hard disk, this example will not work properly because in test movie mode Flash<br />

Player loads local files in their entirety.<br />

// create a new XML document<br />

var doc:XML = new XML();<br />

var checkProgress = function(xmlObj:XML) {<br />

var bytesLoaded:Number = xmlObj.getBytesLoaded();<br />

var bytesTotal:Number = xmlObj.getBytesTotal();<br />

var percentLoaded:Number = Math.floor((bytesLoaded / bytesTotal ) 100);<br />

trace ("milliseconds elapsed: " + getTimer());<br />

trace ("bytesLoaded: " + bytesLoaded);<br />

trace ("bytesTotal: " + bytesTotal);<br />

trace ("percent loaded: " + percentLoaded);<br />

trace ("---------------------------------");<br />

}<br />

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

clearInterval(intervalID);<br />

trace("intervalID: " + intervalID);<br />

}<br />

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

var intervalID:Number = setInterval(checkProgress, 100, doc);<br />

See also<br />

getBytesTotal (XML.getBytesTotal method)<br />

XML 1315

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

Saved successfully!

Ooh no, something went wrong!