[lime.Assets] There is no String asset with an ID of "img/awesome game.json"

There is a way to use assets created at runtime?

openfl 4.2.0
lime 3.2.1

wild guess: spaces might always be a problem

I try this: mygame.json
but [lime.Assets] There is no String asset with an ID of “img/myGame.json”

I think the problem is whem you create the assets at run time.
If i use the same “awesome game.json” file in assets before compilation it works, but if i create the file at runtime it crash, is something with the ID in assets i think it dont exist. Or i need to create that ID for the assets that i create at runtime. But dont know how

You need to use FileSystem if it’s at run time. Assets does not work unless you complie with the assets already there.

Yeah, at runtime you would use something like:

var text = File.getContent ("img/awesome game.json");
var json = Json.parse (text);
trace (json.property);

(unless it is Android, be aware that your APK is zipped, and you cannot use ordinary file operations on your packaged asset files)

Hi Sing!
The target is mac, i already use the File.getContent aproach but it crashes,
Is the same code but i dont know what happen… maybe the File.getContent take more time to load the text than Assets.getText ?

public function updateGamePath(path:String):Void
		// refresh path
		this.path = path;
		// load new library
		// delete old objects
		if(this.img != null)
			this.img = null;
			this.img_level = null;
		// get graphics
		// var string:String = Assets.getText("img/" + this.path + ".json");
		var string:String = sys.io.File.getContent("img/" + this.path + ".json");
		this.img = Json.parse(string);
		// get levels
		// var string1:String = Assets.getText("img/" + this.path + "1.json");
		var string1:String = sys.io.File.getContent("img/" + this.path + "1.json");
		this.img_level = Json.parse(string1);

Perhaps try and see what Sys.getCwd () returns, it’s possible your working directory is different than the asset folder (so you might need “Contents/img” or something like that)

You can also use Assets.getPath ("known asset"); and use that as a reference to find the path to other assets which may appear at runtime.