[HTML5] Starling's Assetmanager

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.


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() 
        var arrayOfAssets:Array<String> = [];
            trace("Loading assets, progress:", ratio);
            if (ratio == 1.0)
                var img:Image = new Image(assets.getTexture("test"));

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
$backend_html5_HTML5HTTPRequest.__loadImage/< HTML5HTTPRequest.hx:456:3

Can Starling load svg format? Is there a problem with the path?:zipper_mouth_face:

Hi rainy.

Yes, the AssetManager can load SVGs since it’s just text. Starling just can’t display those directly.
My problem is loading bitmaps in general which is not path related.

Obviously the problem is caused by this line:

which tries to dispose a BitmapData which doesn’t exist - if deploying to HTML5.
Targeting Flash, trace(asset.bitmapData) returns [object BitmapData] as expected.
If I remove this line of the AssetManager, HTML5 works just fine and I can see my image.
I’m wondering - should we do it like this:

#if !html5

Yeah, maybe it should be if (asset.bitmapData != null) or should be #if flash.

Does this still have a problem with the latest Starling Haxe sources? Thanks :slight_smile: