package openfl.utils { import openfl.text.Font; import openfl.media.Sound; import openfl.display.BitmapData; /** * The IAssetCache interface provides methods for caching * resources loaded from openfl.utils.Assets to improve * performance. * * @externs */ public interface IAssetCache { /** * Whether caching is currently enabled. * */ function get enabled():Boolean; function set enabled(value:Boolean):void; /** * Clears all cached assets, or all assets with an ID that * matches an optional prefix. * * For example: * * ```haxe * Assets.setBitmapData("image1", image1); * Assets.setBitmapData("assets/image2", image2); * * Assets.clear("assets"); // will clear image2 * Assets.clear("image"); // will clear image1 * ``` * * @param prefix A ID prefix * */ function clear(prefix:String = undefined):void; /** * Retrieves a cached BitmapData. * * @param id The ID of the cached BitmapData * @return The cached BitmapData instance * */ function getBitmapData(id:String):openfl.display.BitmapData; /** * Retrieves a cached Font. * * @param id The ID of the cached Font * @return The cached Font instance * */ function getFont(id:String):openfl.text.Font; /** * Retrieves a cached Sound. * * @param id The ID of the cached Sound * @return The cached Sound instance * */ function getSound(id:String):openfl.media.Sound; /** * Checks whether a BitmapData asset is cached. * * @param id The ID of a BitmapData asset * @return Whether the object has been cached * */ function hasBitmapData(id:String):Boolean; /** * Checks whether a Font asset is cached. * * @param id The ID of a Font asset * @return Whether the object has been cached * */ function hasFont(id:String):Boolean; /** * Checks whether a Sound asset is cached. * * @param id The ID of a Sound asset * @return Whether the object has been cached * */ function hasSound(id:String):Boolean; /** * Removes a BitmapData from the cache. * * @param id The ID of a BitmapData asset * @return `true` if the asset was removed, `false` if it was not in the cache * */ function removeBitmapData(id:String):Boolean; /** * Removes a Font from the cache. * * @param id The ID of a Font asset * @return `true` if the asset was removed, `false` if it was not in the cache * */ function removeFont(id:String):Boolean; /** * Removes a Sound from the cache. * * @param id The ID of a Sound asset * @return `true` if the asset was removed, `false` if it was not in the cache * */ function removeSound(id:String):Boolean; /** * Adds or replaces a BitmapData asset in the cache. * * @param id The ID of a BitmapData asset * @param bitmapData The matching BitmapData instance * */ function setBitmapData(id:String, bitmapData:openfl.display.BitmapData):void; /** * Adds or replaces a Font asset in the cache. * * @param id The ID of a Font asset * @param bitmapData The matching Font instance * */ function setFont(id:String, font:openfl.text.Font):void; /** * Adds or replaces a Sound asset in the cache. * * @param id The ID of a Sound asset * @param bitmapData The matching Sound instance * */ function setSound(id:String, sound:openfl.media.Sound):void; } }