Preloader example for HAXE3/OpenFL
In HAXE/OpenFL you can add a Preloader to your App/Game very easily.
You just need to add this parameter in your project.xml, in the APP tag.
<app main="Main" path="Export" file="Preloader" preloader="Preloader" />
the preloader argument ask for a Class (in this case is Preloader.hx, so it becomes Preloader)
The preloader class HAS to extend NMEPreloader to work.
Also remember you cannot use the assets loader inside the class (use the macro instead)
You should notice the preload will be compiled and used only for Flash and HTML5 targets, in any(?) other target it will be ignored completely
The class has already prepared two objects:
outline:Sprite is the border of the loading bar
progress:Sprite is the loading bar
Inside the onUpdate function (which I overidded in this example) the progress bar will be scaled (only x) to show the loading percentage.
You can see the original class here https://github.com/openfl/openfl-native/blob/master/templates/haxe/NMEPreloader.hx
This project offers a class (Preloader.hx) and a real use. You can use the class in your project like Main.hx does here.
Here's how the preloader looks like. (with automatic fluid scaling on resize)
You can customize the colors very easily, and if you code (and I know you code) you can change the class and make it fit your needs.
You can test an online version here.
https://dl.dropboxusercontent.com/u/683344/akifox/preloader/Preloader.swf
If your connection is very fast I doubt you will see the preloader (the file is just 300kb)
You can use Sloppy (http://www.dallaway.com/sloppy/) to slow down the connection (it's a proxy that delay the data flow). I used that to test my design, you can use it here: just make it pointing to my demo, set to 128k/s, and dive the web like in 1999!