Preloader , now that NMEPreloader is depreciated


Google changed his mind :slight_smile: It called “Launch screen” -

IMHO lightweight apps doesn’t need splash screen, I never add splash screens to my own Android apps.


embedding images using @:bitmap has stopped working for the HTML target using OpenFL 5.0.0 , still working correctly for Flash Neko and Windows targets… !


Could you try this change, and see if it helps?

HTML sound woes, after Howler replaces SoundJS

I’ve tried it - no errors but nothing is loading.


BitmapData.fromBytes won’t work on HTML5 – at least, not instantly. If you do not rely upon bitmapData.width or bitmapData.height, I believe it should work once the image is loaded.

Otherwise, it is important to call loadFromBytes instead to wait asynchronously. I believe the @:bitmap embed adds an “onload” callback parameter as the final argument in the constructor on the HTML5 target, but I’d like to think of a better system long-term

Oh, I almost forgot :slight_smile:


<asset path="Assets/preloader" library="preloader" />
<library name="preloader" embed="true" />

Then I believe that should embed the files under “preloader” as it’s own asset library, which you can load inside of your preloader:

Assets.loadLibrary ("preloader").onComplete (function (_) {
    var bitmapData = Assets.getBitmapData ("preloader:image.png");

That’s an alternative to @:bitmap

HTML5 Preloader

Because embedding image using @:bitmap is broken for html5 target in openFl 5.x.x, I try to use your suggested method.
It works but with some different info.

<assets path="assets/preloader" library="preloader" />
<library name="preloader"  embed="true" />

But isn’t possible to get image just with


This works

 Assets.loadLibrary ("preloader").onComplete (function (_) {
   var bitmapData:BitmapData = Assets.getBitmapData("preloader:assets/preloader/logo.png");
   var bmp:Bitmap=new Bitmap(bitmapData);

full path to the bitmap should be written.


Thanks @restorer! Your solution worked nicely

Would be also interesting to see how to “hold” this windowBackground image until the preloader is at a certain stage. Right now basically the image is displayed quickly, and then the background color of openFL kicks in before the preloader is rendered.

Would be nice to be able to hold the graphic until ready for rendering. ( Maybe hold off on draw events or draw app with alpha 0 ? )


I have tried to use this preloader for HTML5 target:

package com;

import openfl.display.Sprite;

@:keep class Preloader extends Sprite {
	private var progress:Sprite;
	public function new () {
		super ();
		progress = new Sprite (); (0xFF0000); (0, 0, 100, 100);
		addChild (progress);
		progress.scaleX = 0;
	public function onInit ():Void {
		trace ("init");
	public function onLoaded ():Void {
		trace ("loaded");
		var delay = 60;
		addEventListener (Event.ENTER_FRAME, function (_) {
			if (delay == 0) {
				trace ("delayed start");
				dispatchEvent (new Event (Event.COMPLETE));
	public function onUpdate (bytesLoaded:Int, bytesTotal:Int):Void {
		trace ("update: " + bytesLoaded + "/" + bytesTotal);
		if (bytesTotal == 0) {
			progress.scaleX = 0;
		} else {
			progress.scaleX = bytesLoaded / bytesTotal;

and at xml build file, I added <app preloader="com.Preloader" but all I see is a gray background which is defined at <window background="#eeeeee" I am using openFL 6.5.3 , please advice


Just guessing, i am not using a preloader:
Did you try “package;” and <app preloader=“Preloader”


Please look at the CustomPreloader example:

openfl create CustomPreloader
cd CustomPreloader
openfl test html5

It looks like this:

ProgressEvent.PROGRESS then Event.COMPLETE are dispatched as assets are loaded, then if the default is not prevented, Event.UNLOAD is dispatched and your preloader is removed. If you prevent the default, you can delay indefinitely, then dispatch Event.UNLOAD when you ready :slight_smile:


Thanks! by the way, the link above is broken


Oh! Sorry, I just moved it :blush:


Its ok :slight_smile: