# AS3 monitor progress main swf loading (preload)

**URL:** <https://forum.kirupa.com/t/as3-monitor-progress-main-swf-loading-preload/238016>\
**Category:** flash\
**Created:** [September 6, 2007, 10:43am UTC](https://forum.kirupa.com/t/as3-monitor-progress-main-swf-loading-preload/238016 "2007-09-06T10:43:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![giovapaglia](https://avatars.discourse-cdn.com/v4/letter/g/ce73a5/32.png) [@giovapaglia](https://forum.kirupa.com/u/giovapaglia)\
**Post date:** [September 6, 2007, 10:43am UTC](https://forum.kirupa.com/t/as3-monitor-progress-main-swf-loading-preload/238016/1 "2007-09-06T10:43:43Z")

</div>

Never had any problem with loading and monitoring loading progress of external files.  
Having some problems on monitoring progress of downloading of the main swf file…

* * *

In document class constructor:  
I add listeners to loaderInfo of document class…

```auto

loaderInfo.addEventListener(Event.OPEN,openListener);
loaderInfo.addEventListener(ProgressEvent.PROGRESS,progressListener);
loaderInfo.addEventListener(Event.COMPLETE,completeListener);

```

and I create the object I’d like to use to visualize progression  
(using a textfield now, but also tried dynamically drawn graphic bar)

```auto
loaderStatus = new TextField(); 

```

* * *

```auto
private function progressListener (e:ProgressEvent):void 
{
    trace("progress");
            
    var percent:int = e.bytesLoaded / e.bytesTotal * 100;
    loaderStatus.text = "Loading: " + percent + "%";           
}
        
private function completeListener (e:Event):void 
{
    e.target.removeEventListener(ProgressEvent.PROGRESS, progressListener);
    e.target.removeEventListener(Event.COMPLETE, completeListener);
    trace("complete");
    stage.removeChild(loaderStatus);
}

```

the progress and complete listeners give feedback through tracing.  
:thumb:  
the open listeners doesn’t give feedback…  
that’s why I’ve moved the creation of the ‘progression visualizer’  
(whatever it is) inside the constructor of the document class…

I don’t get it…  
why we have a loaderInfo property accessible in root/document class  
if it’s useless to track the downloading of the main file  
:ponder:

I’ve tried to search this and other forums  
but I’ve find only info about preloaders in AS2, preloaders for external content  
essential actionscript 3.0 from colin moock  
has info about making a preloader in flash authoring environment  
but it’s using frame scripts…

shouldn’t be possible to manage all the preloader stuff for the main clip  
directly from the document class? :h:  
I know that I’m new to all this AS3 world but…

hope someone will read this  
have a medium-size project and all my initial assets and class  
have a dimension of approximately 300K so I absolutely need  
a preloader for the main file

Any hints, suggestions, pointers are really appreciated  
Thanks  
Jo

---

<div class="post-metadata">

**Author:** ![peregrinus](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@peregrinus](https://forum.kirupa.com/u/peregrinus)\
**Post date:** [June 12, 2008, 12:48am UTC](https://forum.kirupa.com/t/as3-monitor-progress-main-swf-loading-preload/238016/2 "2008-06-12T00:48:15Z")

</div>

I don’t know if it still helps bit somehow it works here… placed on first frame (which has no content)

```php
stop();

this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,onMainLoadProgress);
this.loaderInfo.addEventListener(Event.COMPLETE,onMainLoadCompletes);

function onMainLoadProgress(event:ProgressEvent):void {
    trace(event.bytesLoaded);
}

function onMainLoadCompletes(event:Event):void {
    //continue to next frame
}

```
