Base64 encoding

I am targeting HTML5 for my project, and I’d like to know how base64 encoding works with graphic, text and sound assets in OpenFl.

I have seen I can encode files and output strings for web pages or .bin files, but how do I read them? Is


what I need (for images at least)?

Yes, that should work for images, though there is a delay as base64 loading in the browser is usually asynchronous

how do I know when loading is complete?

and what are the advantages of using base64?

Depends on experience, I think it works slower than standard images, but you can embed them in JS, embedding an image with OpenFL uses base64 rather than loading from disk

Yes, I have read that decoding is a bit slower than reading the true format (this is obvious, base64 encoded images are bigger…). Maybe it is a good choice if you want to reduce calls to web server (embedding in JS or HTML/CSS as you said), or to encode more files in a single container… or to drive people who want to steal your files crazy :wink: