Dynamic assets re-loading

I was reading the “lime update” mention on the openFl 2.0 announcement, but I could not find a simple demo.
I tested on my window build running “lime update windows” from the source folder, but after that the changed assets are not reloaded. I need to restart the executable, I can be missing something thought,
Are there more documentation or an example of this?

I think it works like this:

(Lime)

image = Assets.getImage ("image.png");
Assets.onChange.add (function () {
    image = Assets.getImage ("image.png");
});

(OpenFL)

bitmapData = Assets.getBitmapData ("image.png");
Assets.addEventListener (Event.CHANGE, function (_) {
    bitmapData = Assets.getBitmapData ("image.png");
});

Basically, when there is a live asset update, the Assets class should dispatch a change event, and should dump the cache. The next time you request an asset, instead of the original, it will return the latest version of that asset file.

There may be minor regressions that crept in (such as the assets not clearing automatically) but this is the gist of how it should. I’m open (and interested!) to your feedback and how this can improve more. I’d love to “file watcher” support done in Haxe, so we could watch from the command-line tools and do the update automatically in the future

1 Like