When I use asynchronous Loader.load() I have access to ProgressEvent where I can track bytesLoaded to display a progress bar (or percentage loaded).
Unfortunately, not all platforms support this method of loading. And while it is possible to use loadBytes to create images, I don’t see how I can create Sound objects this way (I saw some “MP3 from bytes” libraries for Haxe, but I will need OGG format for all other platforms).
This means, that either I have to give up the loading bar or exclude sounds from runtime loading.
Yet I hope there are those who know a solution for this dilemma…
P.S. I couldn’t find documentation for SWF library. If it allows extracting OGG files from loaded swfs, the problem is solved.
In the Flash API, you would use URLLoader for plain data (text or bytes), you would use Loader to load an image, or Sound to load a sound, each one has it’s own completion events (but be aware that you must listen to .contentLoaderInfo on the Loader class)
On OpenFL, we also have some utility methods, such as BitmapData.fromFile, and so on, to shortcut the process and skip the full loading method. On native platforms, things are basically “always loaded” because disk IO goes so fast, though we do have plans to add asynchronous loads in another thread, just to prevent the small amount of burden an asset can cause at times (depending on how the project is designed)
Generally speaking, loading is done on HTML5 and Flash, where you are downloading assets from the web, but elsewhere the assets are packaged already, and do not require a loader
var bytes = Assets.getBytes ("mysound.ogg");
var sound = new Sound ();
sound.loadCompressedDataFromByteArray (bytes, bytes.length);
sound.play ();
Of course, OGG is only supported on native, not Flash. You can load the ByteArray from somewhere else (such as ByteArray.fromBytes (File.getBytes ("mysound.ogg")); to load from disk somewhere, but be aware this might not work as you expect on mobile platforms such as Android)
So, Loader class allows runtime loading of graphics.
Sound class allows runtime loading of sounds.
Only 1 question remains now: what allows runtime loading of TTFs?