Creating a custom OpenFL template to use on FlashDevelop

Hi, I’m using OpenFL to create a swc library. To export it, I hacked the Flash template found at OpenFL folder (just changing the “.swf” extension for “.swc”). How can I create a custom template of my own for the swc export to use on FlashDevelop and leave the original FLash template unchanged?

Try this:

###Create a new “templates” directory

The OpenFL/Lime tools use “template paths”, similar to how source paths work. If you create your own templates directory, you can mirror this file structure to override existing files, or add new ones.

Unfortunately, there is no default template for Flash output (since it requires no extra files) but there is a template for “web” output (used when you do lime test flash -web) so I’ll illustrate how you override that.

If you wanted to override the “index.html”, create your own file at “templates/flash/template/web/index.html”

###Add the “templates” directory to your template path

In your project, add your new templates directory to the list of templates paths, like this:

<template path="templates" />

I would recommend doing this after you include the OpenFL haxelib, to ensure that it takes later precedence, so as to override any existing templates within OpenFL and Lime.

###On the other hand…

I’m not sure if a custom template is what you really want. The real issue is you need to output *.swc instead of *.swf, correct? That won’t be solved by templates, but instead is done within the tools. Is there something you define or do to make Haxe do SWC output instead of SWF output? Perhaps we can pick that up somehow and ensure that we output to an *.swf file extension instead?

In fact the change is tiny: I just need to edit a hxml template file for Flash, changing the file extension, like this:

-swf ::BUILD_DIR::/flash/bin/::APP_FILE::.swf

to

-swf ::BUILD_DIR::/flash/bin/::APP_FILE::.swc

Oh! Gotcha. Well in that case, the above instructions should work – just mirror the template path for the HXML (I think it would be “templates/flash/haxe/debug.hxml” and “templates/flash/haxe/release.hxml”) and you can override with your own edit :smile: