45 lines
1.2 KiB
Haxe
45 lines
1.2 KiB
Haxe
package;
|
|
|
|
import openfl.display.Sprite;
|
|
import openfl.Lib;
|
|
import sys.FileSystem;
|
|
import Assets;
|
|
|
|
class Main extends Sprite {
|
|
public function new() {
|
|
super();
|
|
|
|
Lib.current.addChild(this);
|
|
|
|
// Draw background to verify app is running
|
|
graphics.beginFill(0x3498db, 1);
|
|
graphics.drawRect(0, 0, 800, 600);
|
|
graphics.endFill();
|
|
|
|
|
|
// Get data asset library
|
|
var dataLibrary = openfl.utils.Assets.getLibrary("data");
|
|
var imageLibrary = openfl.utils.Assets.getLibrary("images");
|
|
if (dataLibrary == null) {
|
|
trace("Data library not found");
|
|
return;
|
|
}
|
|
if (imageLibrary == null) {
|
|
trace("Image library not found");
|
|
return;
|
|
}
|
|
|
|
// test a data asset
|
|
var testAsset = dataLibrary.getText("img/placeholder.txt");
|
|
trace("Successfully loaded asset: " + testAsset);
|
|
// test an image asset
|
|
var testImage = imageLibrary.getImage("logo.png");
|
|
trace("Successfully loaded image asset: " + testImage);
|
|
var bitmapData = openfl.display.BitmapData.fromImage(testImage);
|
|
this.addChild(new openfl.display.Bitmap(bitmapData));
|
|
|
|
|
|
|
|
}
|
|
}
|