Google changed his mind It called âLaunch screenâ - https://material.io/guidelines/patterns/launch-screens.html
IMHO lightweight apps doesnât need splash screen, I never add splash screens to my own Android apps.
Google changed his mind It called âLaunch screenâ - https://material.io/guidelines/patterns/launch-screens.html
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⌠!
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
In XML:
<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
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
"preloader:image.png"
This works
Assets.loadLibrary ("preloader").onComplete (function (_) {
var bitmapData:BitmapData = Assets.getBitmapData("preloader:assets/preloader/logo.png");
var bmp:Bitmap=new Bitmap(bitmapData);
addChild(bmp);
});
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;
import openfl.events.Event;
@:keep class Preloader extends Sprite {
private var progress:Sprite;
public function new () {
super ();
progress = new Sprite ();
progress.graphics.beginFill (0xFF0000);
progress.graphics.drawRect (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 (_) {
delay--;
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
Thanks! by the way, the link above is broken
Oh! Sorry, I just moved it
Its ok