Haxe - Embed files like in ActionScript?

In ActionScript, you can do something like this:

[Embed(source = "src/myfile.xml", mimeType = "application/octet-stream")]
private var xml : Class;

and it will embed your file, which will be used in the code. How can I do something like this in Haxe?

+3
source share
4 answers

Haxe allows you to provide information about external resources for embedding in hxml.

You can refer to the document .

+4
source

Everything has changed since the question was asked. With the modern version of haxe you can do:

@:bitmap("test.png") class TestBMD extends BitmapData {}
var bm = new Bitmap(new TestBMD(100,100));
+11
source

/ , @:bitmap, :

import openfl.Assets;
...
var bm = new Bitmap(Assets.getBitmapData("test.png"));
+2

XML is easy to use for haxe. Add -resource myfile.xml@myxml. Then in your code to get the xml string use haxe.Resource.getString("myxml"). Then you can parse this string in xml.

0
source

Source: https://habr.com/ru/post/1763710/


All Articles