works perfect without -minify flag. How can i keep my EI functionality?
And another question. Every my asset automatically receives to its url anticache number like .../sounds/result.mp3?782875. Every build number is new . Can i manage it by myself or disable it?
You can try using @:keep on your unreferenced methods to prevent Haxe dead-code-elimination from removing them
@:keep public function myFunction ():Void {
...
}
Is the cache-break string hurting something in your project? We do this in order to prevent like-named assets from being wrongfully cached if it changed in your build. The cache break value does not change after your project is compiled, so it will still cache properly for new users
Yes, i know about @:keep and @:keepSub, but i just put example code in constructor of my Main class and nothing happend with -minify. Meta @:keep didn’t help too.
@:keep
class Main extends Sprite
{
@:keep
public function new()
{
super();
ExternalInterface.call("alert", "foobarstring");
}
}
I can find in output js file my marker string:
var Main = function() {
openfl_display_Sprite.call(this);
openfl_external_ExternalInterface.call("alert","foobarstring");
};
After minifying i can’t find it there…
And i'd like to create list of all my assets with hashes and add hash to load requests. Is it possible?
Hmm, perhaps the @:keep is preserving it during the Haxe dead-code elimination step, but minifying (which is unaffected by the flag) may be doing something to it.
Oh, wait, is it not finding “Main” or is it not finding something in “ExternalInterface”?
If you can handle using the same hash value for all your assets, the current behavior is customizable. Otherwise, we’d have to talk more about the value of a unique hash value per asset, and whether we could support that officially
There’s a lot of ways to access and write JavaScript directly when you’re publishing to the HTML5 target
EDIT: …and in this exact case, the Lime window.alert API should also work cross-target, so it shows an alert pop-up on the desktop as well (no support for mobile yet)
package my.custom.code;
@:native("MyCustomCode")
extern class MyCode {
public static function alert (message:String):Void;
public static function otherMethod ():Void;
}
in the final output. The @:native meta is optional – use it if your package + class name is different than what the JavaScript object reference is. This is a type-safe way of using JavaScript. For example, we do extern classes for using Howler.js in Lime: