Archive for June, 2005

Checking a ScrollPane’s download progress (or lack thereof)

Somebody emailed me recently about this topic, so I came up with a quick and dirty solution. Not sure if there’s a better way, but thought that somebody out there may find this useful, so here it is:

1. Drag a ScrollPane component onto your Stage and give it an instance name of my_scrollPane.

2. Add the following ActionScript to frame 1 of the main timeline. (Watch for wrapping lines!)

my_scrollPane.addEventListener(“complete”, myLoaderCompleteListener);
function myLoaderCompleteListener(eventObj:Object):Void {
if ( == -1) { = false;
var t:TextField =“error_txt”, 10,,, 100, 20);
t.autoSize = “left”;
t.text = “unable to load file”;
// continue setting up.
my_scrollPane.contentPath = “”;

3. Save and test.

Because the image file doesn’t exist, the complete event is dispatched to the ScrollPane instance and getBytesTotal() returns -1. The complete listener checks that the image was successfully loaded. If not, the ScrollPane instance is hidden and a text field is created and displays an error message.