Working with assets on html5 target

Hi, I’m trying to load a PNG file using openfl.Assets.getBitmapData on a HTML5 project. However I always get the message [lime.utils.Assets] ERROR: There is no IMAGE asset with an ID of “img/palhaco.png”. Where do I need to save this image file to load it at runtime?

You need to define your resource directories in the project xml. img is like a defined shortcut specified there that links it to the actual directory. Assuming you haven’t changed anything “img/palhaco.png” should refer to /assets/img/palhaco.png

1 Like

Add this in your project.xml: <assets path="assets/img" rename="img" />
You need to have palhaco.png in this path: assets/img (you can put elsewhere but don’t forget to update the path in the xml tag).
After compiling, it will be directly available in img folder. If you don’t use rename parameter, it will be available with assets/img/palhaco.png and not img/palhaco.png.

You can also add embed="false" in this xml tag so it won’t be downloaded during preloading. But you will need to load later with Assets.loadBitmapData

1 Like