I’ve a little trouble with the AssetManager of Starling 1.8.
The following piece of code works flawlessy if targeting flash and I can see the enqueued image after loading finished.
package;
import starling.core.Starling;
import starling.utils.AssetManager;
import starling.display.Sprite;
import starling.display.Image;
import starling.textures.Texture;
import openfl.Assets;
class Test extends Sprite
{
private var assets:AssetManager = new AssetManager();
public function new()
{
super();
var arrayOfAssets:Array<String> = [];
arrayOfAssets.push(Assets.getPath("img/back.svg"));
arrayOfAssets.push(Assets.getPath("img/test.png"));
assets.enqueue(arrayOfAssets);
assets.loadQueue(function(ratio:Float):Void
{
trace("Loading assets, progress:", ratio);
if (ratio == 1.0)
{
var img:Image = new Image(assets.getTexture("test"));
addChild(img);
}
});
}
}
If I deploy to HTML5, all I get is:
TypeError: asset.bitmapData is undefined
process2 AssetManager.hx:881:15
complete AssetManager.hx:1115:11
onLoaderComplete AssetManager.hx:1084:11
dispatchEvent EventDispatcher.hx:217:3
dispatchEvent EventDispatcher.hx:96:8
BitmapData_onLoad Loader.hx:258:1
complete Promise.hx:52:4
onComplete Future.hx:82:9
then/< Future.hx:232:3
complete Promise.hx:52:4
lime$backend_html5_HTML5HTTPRequest.__loadImage/< HTML5HTTPRequest.hx:456:3