Stable state
This commit is contained in:
@@ -1,19 +1,117 @@
|
||||
package;
|
||||
|
||||
import openfl.events.EventDispatcher;
|
||||
import openfl.display.Sprite;
|
||||
import openfl.events.Event;
|
||||
import openfl.display.DisplayObjectContainer;
|
||||
import openfl.events.MouseEvent;
|
||||
import openfl.Assets;
|
||||
import openfl.display.Bitmap;
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.text.TextField;
|
||||
import openfl.text.TextFormat;
|
||||
|
||||
class Main extends Sprite
|
||||
{
|
||||
public function new()
|
||||
{
|
||||
class Main extends Sprite {
|
||||
public function new() {
|
||||
super();
|
||||
dispatchEvent(new openfl.events.Event(openfl.events.Event.ADDED_TO_STAGE, false, false));
|
||||
graphics.beginFill(0xFFF00F, 1);
|
||||
|
||||
// Draw background to verify app is running
|
||||
graphics.beginFill(0x3498db, 1);
|
||||
graphics.drawRect(0, 0, 800, 600);
|
||||
graphics.endFill();
|
||||
|
||||
// Create title
|
||||
var title = new TextField();
|
||||
title.defaultTextFormat = new TextFormat("Arial", 24, 0xFFFFFF, true);
|
||||
title.text = "OpenFL Asset Test";
|
||||
title.width = 400;
|
||||
title.x = 20;
|
||||
title.y = 20;
|
||||
addChild(title);
|
||||
|
||||
// Display info about available assets
|
||||
displayAssetInfo();
|
||||
|
||||
// Try to load and display a text asset
|
||||
loadTextAsset();
|
||||
|
||||
// Debug manifest content
|
||||
debugManifestInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private function displayAssetInfo():Void {
|
||||
var info = new TextField();
|
||||
info.defaultTextFormat = new TextFormat("Arial", 16, 0xFFFFFF);
|
||||
info.width = 760;
|
||||
info.height = 300;
|
||||
info.x = 20;
|
||||
info.y = 60;
|
||||
info.multiline = true;
|
||||
info.wordWrap = true;
|
||||
|
||||
var assetList = openfl.Assets.list();
|
||||
info.text = "Available Assets (" + assetList.length + "):\n";
|
||||
|
||||
for (asset in assetList) {
|
||||
var extension = asset.substr(asset.lastIndexOf(".") + 1).toLowerCase();
|
||||
var typeStr = getAssetTypeFromExtension(extension);
|
||||
info.text += "• " + asset + " [" + typeStr + "]\n";
|
||||
}
|
||||
|
||||
addChild(info);
|
||||
}
|
||||
|
||||
private function getAssetTypeFromExtension(extension:String):String {
|
||||
return switch(extension) {
|
||||
case "jpg", "jpeg", "png", "gif", "bmp": "IMAGE";
|
||||
case "mp3", "ogg", "wav": "SOUND";
|
||||
case "ttf", "otf": "FONT";
|
||||
case "txt", "json", "xml", "csv", "tsv": "TEXT";
|
||||
default: "BINARY";
|
||||
};
|
||||
}
|
||||
|
||||
private function loadTextAsset():Void {
|
||||
var textDisplay = new TextField();
|
||||
textDisplay.defaultTextFormat = new TextFormat("Arial", 14, 0xFFFFFF);
|
||||
textDisplay.width = 760;
|
||||
textDisplay.height = 200;
|
||||
textDisplay.x = 20;
|
||||
textDisplay.y = 380;
|
||||
textDisplay.multiline = true;
|
||||
textDisplay.wordWrap = true;
|
||||
textDisplay.border = true;
|
||||
textDisplay.borderColor = 0xFFFFFF;
|
||||
textDisplay.background = true;
|
||||
textDisplay.backgroundColor = 0x333333;
|
||||
|
||||
var textPath = "data/img/placeholder.txt";
|
||||
|
||||
if (Assets.exists(textPath)) {
|
||||
// Synchronous loading
|
||||
var content = Assets.getText(textPath);
|
||||
textDisplay.text = "Loaded text content from '" + textPath + "':\n\n" + content;
|
||||
} else {
|
||||
// Try alternative paths
|
||||
var altPath = "assets/data/img/placeholder.txt";
|
||||
if (Assets.exists(altPath)) {
|
||||
var content = Assets.getText(altPath);
|
||||
textDisplay.text = "Loaded text content from '" + altPath + "':\n\n" + content;
|
||||
} else {
|
||||
textDisplay.text = "Could not find text asset '" + textPath + "' or '" + altPath + "'";
|
||||
}
|
||||
}
|
||||
|
||||
addChild(textDisplay);
|
||||
}
|
||||
|
||||
private function debugManifestInfo():Void {
|
||||
var debug = new TextField();
|
||||
debug.defaultTextFormat = new TextFormat("Arial", 12, 0xFF0000);
|
||||
debug.width = 760;
|
||||
debug.height = 100;
|
||||
debug.x = 20;
|
||||
debug.y = 540;
|
||||
debug.multiline = true;
|
||||
debug.wordWrap = true;
|
||||
debug.text = Assets.debugManifest();
|
||||
addChild(debug);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user