• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Preloader repeats loading

Explorer ,
Aug 29, 2014 Aug 29, 2014

Copy link to clipboard

Copied

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

...

TOPICS
Development

Views

795

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2014 Sep 03, 2014

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

In face, my effort on creating a preloader originated from the need to create a splash screen for android app. Because unlike iOS app, where you can put the Default.png and Default-568h.png in your icons to create splash screen, android app doesn't take those. I read online that you can achieve this by creating a simple preloader that loads fast and package both swf files in .apk.

If there is any other way to achieve splash screen, then I would not need to use the preloader.

I also read that flesh builder or some commercial tool can add splash screen for android app, but I am using flashdevelop to build my app. Is there a solution there?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

With that knowledge, I think you're out of luck unfortunately. Others here on the forums can correct me if Im wrong, but from my understanding, the black screen you briefly see when loading up an Android app built with AIR is the AIR runtime loading/initializing and nothing can be displayed until that is done. Once it is done loading, your main app SWF is loaded and displayed automatically. So, as far as I know, there is sadly no way to have a splash image like in iOS unless Adobe adds it in. It seems silly that they haven't since they have it for iOS.

On the preloader front for Android apps, Im not experienced with that specific instance of preloading SWFs so there may be challenges or things to consider that Im not familiar with. I have only ever built preloaders for web based Flash players and that where my previous comment came from. Below is a link to these forums from several years ago where someone else posed basically the same issue of not wanting a blank screen at the launch of the appf. His solution was to create a preloader that loaded his main app SWF and the preloader contains the splash image. With this method, you still see the black screen for a brief 1 to 2 seconds while the AIR runtime starts up, but that was considered acceptable.

Since that is what you were doing and having the issue that brought you here in the first place, maybe there is someone else here that has more experience with preloading SWFs in an Android app that could provide insight as to what might be wrong.

Sorry I don't have better news for you

Re: It is possible to get a splash to appear without a blank screen for several seconds?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

Thanks for the information. The post you pointed me to is the one I saw which suggested using a preloader to shorten the blank screen time. With it being a couple years old, I was hoping this Android splash screen problem is conveniently solved by now. I guess not?

The strange thing is, I encounter this problem with my preloader entirely in the flash universe, not on my device. I think the mobile app specifics have not kicked in at this time, so it should be a flash problem. I am using flashdevelop, with which I am at dumb user level. I think it has a template with preloader. I will investigate when I have time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

I wish Adobe would add splash image capability to Android. I wouldn't think it would be that difficult since they did it for iOS but since I have no idea the level of effort required, it may actually take some time to implement it or it could just be a low priority compared to other bugs and features they are working on. I certainly don't want to belittle Adobe as Im just happy they are still supporting AIR and adding new features.

Could it be a FlashDevelop issue? Have you tried the same code in CC or CS6? I pretty much only work in CS6.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

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 ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines