Question

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 to be used in code. How can i do something similar in Haxe?

Was it helpful?

Solution

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

You may refer to the doc.

OTHER TIPS

Things have changed since the time the question was asked. With a modern version of haxe one can do:

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

If specifying width/height annoys you, and if you don't mind not using the @:bitmap metatag, you could do:

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top