Load all images from Asset folder dynamically

I hope the title already says it.

A folder containing lots of images and I want my app to load every image within the folder upon starting.
(And then pack them all into a Vector)

I’d like to not use a list-file or xml of any kind but have the app automatically load everything that’s contained within the folder.
Is this possible? If yes, how do I approach it?

Thanks a lot :slight_smile:

1 Like

Okay, the answer for anyone who’s curious.

FileSystem.readDirectory ( "myDirectory/" );

provides all filenames with extensions in that folder in an Array

and then it’s just


AFAIK, Assets.getBitmapData() only loads files that were present during the compilation, so it’s not really dynamic loading.

Right, if you want to use the Assets class, you have to compile the asset files into the app.

If that works for you, great! But if you want to be able to load from arbitrary folders without needing to compile them in, you’ll have to use URLLoader or similar.

If they are included in the project at compile-time, Assets.list may help with finding files that start with the same prefix :slight_smile:

This might be useful!