title: ActionScript 3: LoaderInfo COMPLETE event doesn't fire after load() and loadBytes()
body: <p>I'm trying to load PNG images with ActionScript with a Loader object. This works fine for some of the images (the INIT and COMPLETE events are fired as expected), for some other it doesn't. I've read in <a href="https://stackoverflow.com/questions/1337011/trouble-with-actionscript-loader-events">this thread</a> that a URLLoader might help, so I tried that, using the loadBytes() function afterwards. Still doesn't work: the URLLoader fires the COMPLETE event, but the LoaderInfo object does not.</p>
  
  <p>I've written a sample class that demonstrates the problem with two files (one working, the other one not).</p>
  
  <pre><code>public class LoaderTest extends MovieClip {
      var output:TextField;
      var loader:Loader;
      var urlLoader:URLLoader;
  
      function LoaderTest() {
          output = new TextField();
          output.width = 1000;
          output.height = 1000;
          output.multiline = true;
          addChild(output);
  
          var t1:Timer = new Timer(0, 0);
          t1.addEventListener(TimerEvent.TIMER, function() {
              t1.stop(); loadMapDirect("map_in_big.png");
          });
  
          var t2:Timer = new Timer(1000, 0);
          t2.addEventListener(TimerEvent.TIMER, function() {
              t2.stop(); loadMapDirect("map_us_big.png");
          });
  
          var t3:Timer = new Timer(2000, 0);
          t3.addEventListener(TimerEvent.TIMER, function() {
              t3.stop(); loadMapBytes("map_in_big.png");
          });
  
          var t4:Timer = new Timer(3000, 0);
          t4.addEventListener(TimerEvent.TIMER, function() {
              t4.stop(); loadMapBytes("map_us_big.png");
          });
  
          t1.start();
          t2.start();
          t3.start();
          t4.start();
  
      }
  
      function loadMapBytes(url:String):void {
          try {
              urlLoader = new URLLoader();
              urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
              urlLoader.addEventListener(ProgressEvent.PROGRESS, progressListener);
              urlLoader.addEventListener(Event.COMPLETE, completeListenerBytes);
  
              output.appendText("\nLoading '"+url+"' with URLLoader ");
              urlLoader.load(new URLRequest(url));
          } catch (error:Error) {
              output.appendText("Err: " + error.message + "\n");
          }
  
      }
  
      function completeListenerBytes(e:Event):void {
          output.appendText("COMPLETE Event fired for URLLoader!\n");
  
          try {
              loader = new Loader();
              loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
              loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListenerDirect);
              output.appendText("Loading bytes with Loader ");
              loader.loadBytes(e.target.data as ByteArray);
          } catch (error:Error) {
              output.appendText("Err: " + error.message + "\n");
          }
      }
  
      function loadMapDirect(url:String):void {
          try {
              loader = new Loader();
              loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
              loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListenerDirect);
  
              output.appendText("\nLoading '"+url+"' with Loader ");
              loader.load(new URLRequest(url));
          } catch (error:Error) {
              output.appendText("Err: " + error.message + "\n");
          }
      }
  
      function completeListenerDirect(e:Event):void {
          var bmd:BitmapData = Bitmap(e.target.loader.content).bitmapData;
          output.appendText("COMPLETE Event fired for Loader! =&gt; h: " +  bmd.height + ", w: " + bmd.width + "\n");
      }
  
      function progressListener (e:ProgressEvent):void{
          output.appendText(".");
          if (e.bytesLoaded == e.bytesTotal) {
              output.appendText(" progress complete, " + e.bytesTotal + " bytes loaded!\n");
          }
      }
  }
  </code></pre>
  
  <p>All images were generated with the PHP GD library and I'm compiling with SWFTools's as3compile.</p>
  
  <p>You can see the script it in action on <a href="http://www.wichte-sind-wichtig.de/as3loader/loaderTest.swf" rel="nofollow noreferrer">http://www.wichte-sind-wichtig.de/as3loader/loaderTest.swf</a></p>
  
  <p>The two images map_in_big.png and map_us_big.png are in the same folder (not allowed to post more hyperlinks).</p>
  
  <p>Any ideas?</p>