Skip to main content
Inspiring
August 30, 2014
Question

Preloader repeats loading

  • August 30, 2014
  • 1 reply
  • 942 views

I have the following preloader,

package

{

  import flash.display.Loader;

  import flash.display.Sprite;

  import flash.events.Event;

  import flash.events.ProgressEvent;

  import flash.net.URLRequest;

  public class Main extends Sprite

  {

  private var l:Loader = new Loader();

  public function Main():void {

  l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loop);

  l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

  trace("loading ...");

  l.load(new URLRequest("./myapp.swf"));

  }

  private function loop(e:ProgressEvent):void

  {

  trace("loaded " + e.bytesLoaded + " bytes");

  }

  private function done(e:Event):void {

  trace("done");

  addChild(l);

  }

  }

}

I expect it to load myapp.swf and display it when done. But it seems to load it again and again, as I have the following output. It goes on like that endlessly and never displays myapp.swf. What is going on?

loading ...

loaded 0 bytes

loaded 65536 bytes

...

loaded 9448859 bytes

loading ...

done

loaded 0 bytes

loaded 65536 bytes

...

loaded 9448859 bytes

loading ...

done

loaded 0 bytes

loaded 65536 bytes

...

This topic has been closed for replies.

1 reply

September 3, 2014

Can you add an IO Error event listener to your Loader and see if anything happens there?

l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

private function onIOError(e:IOErrorEvent):void {

trace(e.text)

}

Also, does your loaded SWF have to be explicitly initialized with an init() function (or something similar) or does it just work once it is loaded/running?

Inspiring
September 4, 2014

Thank you so much for your suggestions.

I have added eventlistener on io error as you suggested, but it didn't catch any error.

My swf had no init() function. Just to test, I renamed my main() function to init and added a main() just to call init(). The result is the same as before (keeps loading again and again).

I also created a very simple swf with the following code,

package

{

  import flash.ui.*;

  import flash.display.*;

  public class Main extends Sprite

  {

  public function Main():void

  {

  init();

  }

  private function init():void

  {

  this.graphics.lineStyle(5, 0xFF0000);

  this.graphics.drawCircle(100, 100, 100);

  }

  }

}

Loading this swf file in my preloader gives me the following message in the debug window,

loading ...

loaded 0 bytes

loaded 802 bytes

Process not responding.

Process not responding.

....

I don't know why it is different now. Both swf plays fine in flash player. I did notice, in flash player, the control is set to loop and grayed out. Any more suggestion is greatly appreciated. Thank you.

September 4, 2014

It is definitely a FlashDevelop issue. I think if you use flash builder, splash screen is not a problem. (Adobe Flex 4.6 * Define a mobile application and a splash screen)

But being poor, I don't have flash builder or CS6 or anything that is not free ...


Haha I hear you on that one. CS6 Design Premium hurt my wallet. It got so light, I expected it to float away like a birthday balloon.