ソースを参照

implemented loadBitmap

ncannasse 9 年 前
コミット
fae32bfbd5
1 ファイル変更13 行追加0 行削除
  1. 13 0
      hxd/fs/BytesFileSystem.hx

+ 13 - 0
hxd/fs/BytesFileSystem.hx

@@ -48,7 +48,20 @@ class BytesFileEntry extends FileEntry {
 	}
 	}
 
 
 	override function loadBitmap( onLoaded : LoadedBitmap -> Void ) : Void {
 	override function loadBitmap( onLoaded : LoadedBitmap -> Void ) : Void {
+		#if flash
+		var loader = new flash.display.Loader();
+		loader.contentLoaderInfo.addEventListener(flash.events.IOErrorEvent.IO_ERROR, function(e:flash.events.IOErrorEvent) {
+			throw Std.string(e) + " while loading " + fullPath;
+		});
+		loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function(_) {
+			var content : flash.display.Bitmap = cast loader.content;
+			onLoaded(new hxd.fs.LoadedBitmap(content.bitmapData));
+			loader.unload();
+		});
+		loader.loadBytes(bytes.getData());
+		#else
 		throw "TODO";
 		throw "TODO";
+		#end
 	}
 	}
 
 
 	override function exists( name : String ) : Bool return false;
 	override function exists( name : String ) : Bool return false;