Skip to content

Live asset reloading

Mark Knol edited this page Jun 25, 2014 · 7 revisions

Since Flambe 3, you can update assets, and see them change directly in the browser. This works in a debug build. This means when you update images, animations or other files, you don't need to recompile or even press refresh in your browser! 😝

♻️ Detect a reload

You can simply listen to the changed-signal on the reloadCount of the Asset.

To test it, place a "my_file.txt" in your assetpack, build the project. Then watch the browser and your trace-console after you make changes in the file, while the project runs in your browser.

// pack refers to an AssetPack
var myFile:File = pack.getFile("my_file.txt");
trace("myFile content: " + myFile.toString());

// connect to reload count to detect asset reload
myFile.reloadCount.changed.connect(function(to:Int, from:Int)
{
	trace("file reloaded. new content: " + myFile.toString());
});

Learn more about using Signals on Signal Event System

Clone this wiki locally