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 fil开发者_JAVA百科e to be used in code. How can i do something similar in Haxe?
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));
Haxe allows you to provide external resources info for embedding in hxml.
You may refer to the doc.
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.
精彩评论