title: Progress indicator using flash.display.Loader
body: <p>I need to do a simple progress indicator while loading an image on background. I’m using the flash.display.Loader class in what seems to be the standard way. The problem is that even though I can see that flash.display.LoaderInfo fires the ProgressEvent.PROGRESS at regular intervals using tracing, a dynamically updated text (or any other graphics object) is updated only once when the loading finishes. It looks like if the display update queued and caused only one update at the end. This is a simplified version of the function which initiates the loading:</p>
  
  <pre><code>public function init()
  {
      var loader : Loader = new Loader(); 
      var request : URLRequest = new URLRequest(this.imageSrc); 
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
      loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, updateProgress);
      loader.load(request);
  }
  </code></pre>
  
  <p>and this is the event handler:</p>
  
  <pre><code>private function updateProgress(event : ProgressEvent) : void
  {
      progressIndicator.text = event.bytesLoaded + " / " + event.bytesTotal;
      trace(event.bytesLoaded + " / " + event.bytesTotal);
  }
  </code></pre>
  
  <p>I apologize for probably an elementary question. I don’t use Flash very often. But it seems to me that I’m doing a sensible and intuitive thing. It must be some 101 Flash pitfall.</p>