View comments | RSS feed

ScrollPane.getBytesLoaded()

Availability

Flash Player 6 (6.0 79.0).

Edition

Flash MX 2004.

Usage

scrollPaneInstance.getBytesLoaded()

Parameters

None.

Returns

The number of bytes loaded in the scroll pane.

Description

Method; returns the number of bytes loaded in the ScrollPane instance. You can call this method at regular intervals while loading content to check its progress.

Example

This example creates a ScrollPane instance called scrollPane. It then defines a listener object called loadListener with a progress event handler that calls getBytesLoaded() to help determine the progress of the load:

createClassObject(mx.containers.ScrollPane, "scrollPane", 0);
loadListener = new Object();
loadListener.progress = function(eventObj){  
   // eventObj.target is the component that generated the change event 
   var bytesLoaded = scrollPane.getBytesLoaded();
   var bytesTotal = scrollPane.getBytesTotal();
   var percentComplete = Math.floor(bytesLoaded/bytesTotal);
    
   if (percentComplete < 5)  // loading begins
   {        
      trace(" Starting loading contents from Internet"); 
   } 
   else if(percentComplete = 50) // 50% complete
   { 
      trace(" 50% contents downloaded "); 
   }
}
scrollPane.addEventListener("progress", loadListener);
scrollPane.contentPath = "http://www.geocities.com/hcls_matrix/Images/homeview5.jpg";

Comments


Brando said on Oct 23, 2004 at 8:25 PM :
There are a couple errors in this example. Firstly, the line:

var percentComplete = Math.floor(bytesLoaded/bytesTotal);

should read:

var percentComplete:Number = Math.floor((bytesLoaded/bytesTotal) * 100);

Plus this line:

else if(percentComplete = 50)

should read:

else if(percentComplete == 50)
jepo said on Oct 30, 2004 at 10:03 PM :
Thanks! I have filed a documentation bug so this gets fixed.

Jen.

 

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/00002773.html