In addition to openfl.Assets
, OpenFL supports @:bitmap
, @:sound
, @:font
and @:file
embed tags.
The former requires <assets path="to/assets" />
in your project XML file, and on Windows, will copy the files alongside your executable.
The embed tags require that your asset files are in your source path based on the way they are embedded, so use <source path="to/assets" />
in the project file.
Here is an example that uses the @:bitmap
tag:
package;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
@:bitmap("nme.png") class Image extends BitmapData {}
class Main extends Sprite {
public function new () {
super ();
var bitmap = new Bitmap (new Image (0, 0));
addChild (bitmap);
bitmap.x = (stage.stageWidth - bitmap.width) / 2;
bitmap.y = (stage.stageHeight - bitmap.height) / 2;
}
}
Using embed tags, the asset will be inside your executable.