Image Utilities - Load File Async with assets

I was wondering if it’s possible to load an asset image asynchronously using Load Async method from Image Utilities.

I’m able to use it with pictures from URLs, but couldn’t manage to load a PNG included inside the project assets.

I tried using Make Full Path method from File, providing both “App” and “Asset” scopes. Also, I tried removing and leaving the prefix “file://”, no luck in any of these attempts.

I know file scopes are discussed extensively and I’ve read a good part of the documentation offered in past posts already. Maybe it’s a little detail I’m missing.

Any comments would be appreciated. Thank you.

Try starting your asset path with //, e.g. //mydog.png.

I did a replace of “file:///” to “/”. It works on the Companion app, but fails to show image when running compiled.

Here’s the blocks if anyone cares to take a look:

Don’t make a full path. Just directly use //mydog.png, with the asset in its simplest form, in your case, //chat.png.

Tha didn’t do it, unfortunately. Here’s the blocks:

I feel silly. I did a version with only “filename.png”, without any path or slashes and it worked.

It still fails on the companion app, but at least it’s working on compiled version for deployment.

Here’s the blocks working version:

I’ll go with that for now, until I find a better solution that works on the companion too.
Thank you for your quick response!

I have a last resort, that should work on all versions, companion and APK. This basically copies the file from the asset over to the ASD, then generates an absolute path.

Tested on Android 7 and 11, both companion and APK.

ImageUtilAsync.aia (6.8 KB)

What I did is initialize a global var to store the path as empty:

Then, at screen initialization, test if app is running from companion. Case is true, set that global var to the assets path:

Finally, on Load Async, concatenate the variable with filename, like this:

This way, when running compiled, it just ignores any path and uses the bare filename.

Hope it helps.

You don’t have to check if it is the companion or whatsoever. Just use the blocks in my previous post, replace the image with your image and the asset with your asset, and try. As I told you, the blocks copy the asset file to the ASD and then loads it from the ASD.

Also, mark the post with the correct solution. The current solution does not work in the Companion.

Yes, your approach is a good one.

I just thought on offering an alternative. Say you’re dealing with many assets, then copying all of them could be costfull to the app.

Both ways are viable solutions. Thanks, appreciate your help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.