The OpenFL library for Haxe contains a number of template files that are used when building a project. You can find them in the assets/templates directory. Using the <template>
element in project.xml, it's possible to replace one or more of these template files with custom versions, on a per-project basis, and without forking OpenFL.
This sample project contains a directory named custom-templates. It is configured in project.xml like this:
<template path="custom-templates"/>
Inside custom-templates, there's a file at haxe/ApplicationMain.hx. The relative path to this file matches the file named haxe/ApplicationMain.hx inside OpenFL's assets/templates directory.
The custom haxe/ApplicationMain.hx template file contains several trace()
calls during the OpenFL initialization process. To confirm that the custom haxe/ApplicationMain.hx is being used by the project, compile and run, and check the debug console for output.
openfl test html5
This custom haxe/ApplicationMain.hx is a simplified version of the default one used by OpenFL. It doesn't create a preloader or load any assets, and it removes the macros that enable some more advanced features that most projects don't need.
Sample created by Josh Tynjala, the author of Feathers UI and core contributor to OpenFL.