lime icon indicating copy to clipboard operation
lime copied to clipboard

Assets.isLocal give different result if you specify the AssetType or not

Open loudoweb opened this issue 5 years ago • 1 comments

Assets.loadLibrary ("delayed").onComplete (function (library) {
     trace(Assets.isLocal("delayed:assets/stars.mp3", cast "SOUND")); //true
     trace(Assets.isLocal("delayed:assets/stars.mp3"));//false (should be true, right?)
                
     sound = Assets.getSound ("delayed:assets/stars.mp3");
            
     trace(Assets.isLocal("delayed:assets/stars.mp3", cast "SOUND"));//true
     trace(Assets.isLocal("delayed:assets/stars.mp3"));//true
}

loudoweb avatar Oct 22 '18 17:10 loudoweb

Glancing at the source code, it's obvious enough why this happens.

return switch (requestedType)
{
	case IMAGE:
		cachedImages.exists(id);

	case MUSIC, SOUND:
		cachedAudioBuffers.exists(id);

	case FONT:
		cachedFonts.exists(id);

	default: cachedBytes.exists(id) || cachedText.exists(id);
}

Probably meant to be an optimization, but maps are pretty fast, so I doubt it matters much.

player-03 avatar Jun 07 '22 02:06 player-03