title: Flash preloader: Not preloading properly?
body: <p>The preloader does not show up after 3% like it should have, it shows up when the file has loaded entirely.</p>
  
  <p>Can someone help explain to me what I am doing wrong? My code is in the first frame, and it makes use of a rectangle object, and a textfield object. In other preloaders I have seen with code like this, it uses a movieclip with 100 frames. Does that make the difference? I have code updating the width of the rectangle, and something to update the text in the dynamic textbox as well.</p>
  
  <p>My entire code in the first frame:</p>
  
  <pre><code>import flash.display.MovieClip;
  import flash.events.ProgressEvent;
  
  function update(e:ProgressEvent):void {
      //trace(e.bytesLoaded);
      if (loader) {
          loader.text = Math.round(e.bytesLoaded*100/e.bytesTotal).toString() + " %";
      }
      if (bar) {
          bar.width = Math.round(e.bytesLoaded*100/e.bytesTotal)*2;
      }
  
  }
  loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
  var loader:TextField = new TextField();
  var bar:preloader_bar = new preloader_bar();
  addEventListener(Event.ENTER_FRAME, checkFrame);
  
  var loaderTextFormat:TextFormat = new TextFormat("_sans", 16, 0x000000, true);
  loaderTextFormat.align = TextFormatAlign.CENTER;
  loader.defaultTextFormat = loaderTextFormat;
  bar.color = 0x000000;
  addChild(bar);
  addChild(loader);
  
  
  // Extra test for IE
  var percent:Number = Math.floor( (this.loaderInfo.bytesLoaded*100)/this.loaderInfo.bytesTotal );
  if (percent == 100) {
      nextFrame();
  }
  stop();
  
  
  if (loader) {
      loader.x = (stage.stageWidth - loader.width) / 2;
      loader.y = stage.stageHeight / 2;
  }
  if (bar) {
      bar.x = (stage.stageWidth - 200) / 2;
      bar.y = (stage.stageHeight - bar.height) / 2;
  }
  
  function checkFrame(e:Event):void {
      if (currentFrame == totalFrames) {
          removeEventListener(Event.ENTER_FRAME, checkFrame);
          startup();
      }
  }
  function startup():void {
      // hide loader
      stop();
      loaderInfo.removeEventListener(ProgressEvent.PROGRESS, update);
      var mainClass:Class = Main as Class;
      addChild(new mainClass() as DisplayObject);
  }
  </code></pre>
  
  <p>It really should be showing up, is there some fancy export option I need to change? I tried this with the bandwidth profiler, it only shows anything after the 100% mark.</p>
  
  <p>EDIT: progress_bar is a movieclip which was exported for actionscript.</p>