The OpenFL library for Haxe provides a very simple, unobtrusive preloader by default. You can view the openfl.display.Preloader class to see how it works. In some cases, you may want to provide your own preloader with custom graphics and animations, or you may want to prevent the preloader from unloading until an animated intro completes or until the user is interacts with it in some way, such as by clicking a start button.
This sample project contains a class named com.example.MyCustomPreloader that replaces OpenFL's default preloader. It displays a custom progress bar, a TextField that displays the current percentage of asset data that has been loaded, and a button for the user to manually dismiss the preloader when it completes.
The custom preloader is configured in project.xml like this:
<app preloader="com.example.MyCustomPreloader"/>To confirm that the custom preloader is being used by the project, compile and run in a web browser. You may need to enable network throttling in your web browser's developer tools to see the progress bar and percentage label update.
openfl test html5 -debugSample created by Josh Tynjala, the author of Feathers UI and a member of the OpenFL leadership team.