Hi Omega,
I would recommend getting the embedded assets branch working before merging the preloader branch--probably. Also keep in mind that the embedded assets branch basically depends on also pulling the asynchronous initialization branch (
https://github.com/purplepwny/flambe/commit/d29c102) and using it by waiting for System.init's new promise. I think that point is catching a lot of people.
If you get to the point where you are in fact ready for a preloader, this is the entirety of my preloader for Super Murderwolf, which I adapted from here (
http://old.haxe.org/doc/flash/preloader):
package preloader;
import flash.Lib;
import flash.display.Sprite;
import flash.events.Event;
import haxe.Timer;
class Preloader extends Sprite
{
public function new()
{
super();
addEventListener(Event.ENTER_FRAME, onLoadProgress);
progress_bar = new Sprite();
addChild(progress_bar);
}
function onLoadProgress(event:Event):Void
{
var bytesLoaded = Lib.current.stage.loaderInfo.bytesLoaded;
var bytesTotal = Lib.current.stage.loaderInfo.bytesTotal;
var percentLoaded = bytesLoaded / bytesTotal;
progress_bar.graphics.clear();
var bar_width = 350;
var bar_height = 50;
progress_bar.graphics.beginFill(0x9b3730);
progress_bar.graphics.drawRect(-bar_width / 2, -bar_height / 2, bar_width * percentLoaded, bar_height);
progress_bar.x = stage.stageWidth / 2;
progress_bar.y = stage.stageHeight / 2;
progress_bar.graphics.endFill();
if ( percentLoaded == 1 )
{
removeEventListener(Event.ENTER_FRAME, onLoadProgress);
Lib.current.removeChild(this);
var cls = Type.resolveClass("nss.Main");
untyped cls.main();
}
}
public static function main()
{
var preloader = new Preloader();
Lib.current.addChild(preloader);
}
private var progress_bar : Sprite;
}