Search code examples
haxeopenflhaxeflixel

Is it possible to list embedded folder contents?


Is it possible to list embedded folder contents?

I want to load all files from specific folder(s), w/o having to edit file list after adding each new file.

Edit:

If I try sys.FileSystem.ReadDirectory(), I get a

"You cannot access the sys package while targeting flash (for sys.FileSystem)"

error for Flash. But when I look in HaxeFlixel FlxAssets.hx file - somehow it does the trick for flash target.

How?


Solution

  • You can get an array containing the paths to all embedded images like so:

    import openfl.Assets;
    
    var imagePaths:Array<String> = Assets.list(AssetType.IMAGE);
    

    If you don't specify an AssetType, list() returns all embedded assets regardless of their type.