Skip to main content
July 22, 2010
Question

URLLoader Event.COMPLETE dispatched when data not completely loaded?

  • July 22, 2010
  • 2 replies
  • 1276 views

I am experiencing an interesting problem...I have a URLLoader instance with a Event.COMPLETED listener. I can reproduce behavior such that when the listener is called, there is a discrepancy in the amount of loaded data.

Here's a snippet from the listener tracing the data...

var loader:URLLoader = URLLoader(event.target);

trace(loader.bytesLoaded);

trace(loader.bytesTotal);

trace(loader.data.length);

My trace shows (during one test...)

46067

65536

46067

So, we have a case where: loader.bytesLoaded == loader.data.length, but loader.bytesLoaded != loader.bytesTotal.

With bytesLoaded not equal to bytesTotal, that means the data is not loaded, yet by listener was called. I have sniffed the net traffic and it does report seeing a HTML response of 64k in size.

How is it this possible? All of the docs state that Event.COMPLETED is called when the data is completed loaded, yet tracing the properties of the loader clearly indicates that the data is not completed loaded! Is this a new wrinkle with the newest players?

I am using the latest FLASH player as of 7/20/2010, CS4 10.0.2; running on XP SP3

thanks,

bob

This topic has been closed for replies.

2 replies

Participant
March 19, 2016

I meet the same trouble. the code was very normal. And it is very easy to turn up when use some tool to limit the net speed .

var urlLoader:URLLoaderItem = new URLLoaderItem();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE , onOneItemLoaded );
urlLoader.addEventListener(IOErrorEvent.IO_ERROR , onOneItemIOError );

package engine.scene.map.loader

{

  import flash.net.URLLoader;

   /**

   * 配合MapAssetLoader ,完成地图资源的加载

   * */

  public class URLLoaderItem extends URLLoader

  {

  public function URLLoaderItem()

  {

  super();

  }

  public var resKey:int ;

  public var curStatus:int = 0;

  }

}

Inspiring
July 22, 2010

Without seeing more code, it would be hard to say what the problem is.  In particular, it would be interesting to see where those trace statements live.