diff --git a/lime/tools/platforms/FlashPlatform.hx b/lime/tools/platforms/FlashPlatform.hx index 34b6db24f..ba67f8df8 100644 --- a/lime/tools/platforms/FlashPlatform.hx +++ b/lime/tools/platforms/FlashPlatform.hx @@ -4,6 +4,7 @@ package lime.tools.platforms; import haxe.io.Path; import haxe.Json; import haxe.Template; +import lime.tools.helpers.AssetHelper; import lime.tools.helpers.CompatibilityHelper; import lime.tools.helpers.DeploymentHelper; import lime.tools.helpers.FileHelper; @@ -38,7 +39,7 @@ class FlashPlatform extends PlatformTarget { super (command, _project, targetFlags); targetDirectory = project.app.path + "/flash/" + buildType; - + } @@ -237,6 +238,11 @@ class FlashPlatform extends PlatformTarget { var destination = targetDirectory + "/bin/"; PathHelper.mkdir (destination); + project = project.clone (); + + AssetHelper.createManifest (project, PathHelper.combine (targetDirectory, "obj/manifest")); + project.haxeflags.push ("-resource " + targetDirectory + "/obj/manifest@__ASSET_MANIFEST__"); + embedded = FlashHelper.embedAssets (project, targetDirectory); var context = generateContext (); @@ -286,6 +292,8 @@ class FlashPlatform extends PlatformTarget { } + AssetHelper.createManifest (project, PathHelper.combine (targetDirectory, "obj/manifest")); + } diff --git a/lime/utils/AssetLibrary.hx b/lime/utils/AssetLibrary.hx index 4d9ad3a07..922576aad 100644 --- a/lime/utils/AssetLibrary.hx +++ b/lime/utils/AssetLibrary.hx @@ -104,6 +104,8 @@ class AssetLibrary { public static function fromManifest (manifest:AssetManifest):AssetLibrary { + if (manifest == null) return null; + var library:AssetLibrary = null; if (manifest.libraryType == null) { @@ -486,7 +488,11 @@ class AssetLibrary { } else if (classTypes.exists (id)) { + #if flash + return Future.withValue (Bytes.ofData (Type.createInstance (classTypes.get (id), []))); + #else return Future.withValue (Type.createInstance (classTypes.get (id), [])); + #end } else { diff --git a/lime/utils/AssetManifest.hx b/lime/utils/AssetManifest.hx index b81c8c05d..66c8573d1 100644 --- a/lime/utils/AssetManifest.hx +++ b/lime/utils/AssetManifest.hx @@ -77,6 +77,8 @@ class AssetManifest { public static function parse (data:String):AssetManifest { + if (data == null || data == "") return null; + #if !macro var manifestData = Json.parse (data); diff --git a/templates/haxe/DefaultAssetLibrary.hx b/templates/haxe/DefaultAssetLibrary.hx index 4fe5c372c..af2de7e2d 100644 --- a/templates/haxe/DefaultAssetLibrary.hx +++ b/templates/haxe/DefaultAssetLibrary.hx @@ -28,13 +28,6 @@ import sys.FileSystem; super (); - #if flash - - ::if (assets != null)::::foreach assets::::if (embed)::classTypes.set ("::id::", __ASSET__::flatName::);::else::paths.set ("::id::", "::resourceName::");::end:: - types.set ("::id::", AssetType.$$upper(::type::));::end::::end:: - - #else - if (ApplicationMain.config != null && Reflect.hasField (ApplicationMain.config, "assetsPrefix")) { rootPath = Reflect.field (ApplicationMain.config, "assetsPrefix"); @@ -53,7 +46,7 @@ import sys.FileSystem; } - #if (openfl && !display) + #if (openfl && !flash && !display) ::if (assets != null)::::foreach assets::::if (type == "font")::openfl.text.Font.registerFont (__ASSET__OPENFL__::flatName::); ::end::::end::::end:: #end @@ -68,7 +61,7 @@ import sys.FileSystem; #end ::else::::if (embed):: #if html5 preload.set (id, true); - #elseif (desktop || cpp) + #elseif (desktop || cpp || flash) classTypes.set (id, __ASSET__::flatName::); types.set (id, AssetType.$$upper(::type::)); #end @@ -111,8 +104,6 @@ import sys.FileSystem; } - #end - }