From a5b85e357ac559ff15520fce49ee464bf4a4040a Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Wed, 5 Oct 2016 09:47:30 -0700 Subject: [PATCH] Improve DefaultAssetLibrary.isLocal --- templates/haxe/DefaultAssetLibrary.hx | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/templates/haxe/DefaultAssetLibrary.hx b/templates/haxe/DefaultAssetLibrary.hx index 09da910ee..d2efd7755 100644 --- a/templates/haxe/DefaultAssetLibrary.hx +++ b/templates/haxe/DefaultAssetLibrary.hx @@ -412,16 +412,33 @@ class DefaultAssetLibrary extends AssetLibrary { public override function isLocal (id:String, type:String):Bool { - #if (flash || windows || mac || linux) - + #if flash + return className.exists (id); - - #else + + #elseif html5 + var requestedType = type != null ? cast (type, AssetType) : null; - if (requestedType == AssetType.FONT) - return className.exists (id); - else - return path.exists (id); + + return switch (requestedType) { + + case FONT: + + className.exists (id); + + case IMAGE: + + Preloader.images.exists (path.get (id)); + + default: + + Preloader.loaders.exists (path.get (id)); + + } + + #else + + return true; #end