Assets improvements for HTML5

This commit is contained in:
Joshua Granick
2014-06-18 14:50:30 -07:00
parent ec3b0c381e
commit 536e2118b2
3 changed files with 132 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
import ::APP_MAIN::;
import lime.Assets;
class ApplicationMain {
@@ -16,6 +17,23 @@ class ApplicationMain {
preloader.onComplete = start;
preloader.create (config);
#if js
var urls = [];
var types = [];
::foreach assets::::if (embed)::
urls.push ("::resourceName::");
::if (type == "image")::types.push (AssetType.IMAGE);
::elseif (type == "binary")::types.push (AssetType.BINARY);
::elseif (type == "text")::types.push (AssetType.TEXT);
::elseif (type == "sound")::types.push (AssetType.SOUND);
::elseif (type == "music")::types.push (AssetType.MUSIC);
::else::types.push (null);::end::
::end::::end::
preloader.load (urls, types);
#end
}

View File

@@ -3,6 +3,7 @@ package;
import haxe.Timer;
import haxe.Unserializer;
import lime.app.Preloader;
import lime.graphics.ImageData;
import lime.utils.ByteArray;
import lime.Assets;
@@ -154,8 +155,8 @@ class DefaultAssetLibrary extends AssetLibrary {
#elseif js
/*var bytes:ByteArray = null;
var data = ApplicationMain.urlLoaders.get (path.get (id)).data;
var bytes:ByteArray = null;
var data = Preloader.loaders.get (path.get (id)).data;
if (Std.is (data, String)) {
@@ -180,9 +181,7 @@ class DefaultAssetLibrary extends AssetLibrary {
} else {
return null;
}*/
return null;
}
#else
@@ -204,8 +203,8 @@ class DefaultAssetLibrary extends AssetLibrary {
#elseif js
return null;
//return cast (ApplicationMain.loaders.get (path.get (id)).contentLoaderInfo.content, Bitmap).bitmapData;
var image = Preloader.images.get (path.get (id));
return new ImageData (image, image.width, image.height);
#else
@@ -289,8 +288,8 @@ class DefaultAssetLibrary extends AssetLibrary {
#if js
/*var bytes:ByteArray = null;
var data = ApplicationMain.urlLoaders.get (path.get (id)).data;
var bytes:ByteArray = null;
var data = Preloader.loaders.get (path.get (id)).data;
if (Std.is (data, String)) {
@@ -314,9 +313,7 @@ class DefaultAssetLibrary extends AssetLibrary {
} else {
return null;
}*/
return null;
}
#else