The AssetCache class is the default cache implementation used
by openfl.utils.Assets, objects will be cached for the lifetime
of the application unless removed explicitly, or using Assets
unloadLibrary
Constructor
Variables
Methods
clear(?prefix:String):Void
Clears all cached assets, or all assets with an ID that matches an optional prefix.
For example:
Assets.setBitmapData("image1", image1);
Assets.setBitmapData("assets/image2", image2);
Assets.clear("assets"); // will clear image2
Assets.clear("image"); // will clear image1
Parameters:
prefix | A ID prefix |
---|
getBitmapData(id:String):BitmapData
Retrieves a cached BitmapData.
Parameters:
id | The ID of the cached BitmapData |
---|
Returns:
The cached BitmapData instance
getFont(id:String):Font
Retrieves a cached Font.
Parameters:
id | The ID of the cached Font |
---|
Returns:
The cached Font instance
getSound(id:String):Sound
Retrieves a cached Sound.
Parameters:
id | The ID of the cached Sound |
---|
Returns:
The cached Sound instance
hasBitmapData(id:String):Bool
Checks whether a BitmapData asset is cached.
Parameters:
id | The ID of a BitmapData asset |
---|
Returns:
Whether the object has been cached
hasFont(id:String):Bool
Checks whether a Font asset is cached.
Parameters:
id | The ID of a Font asset |
---|
Returns:
Whether the object has been cached
hasSound(id:String):Bool
Checks whether a Sound asset is cached.
Parameters:
id | The ID of a Sound asset |
---|
Returns:
Whether the object has been cached
removeFont(id:String):Bool
removeSound(id:String):Bool
setBitmapData(id:String, bitmapData:BitmapData):Void
Adds or replaces a BitmapData asset in the cache.
Parameters:
id | The ID of a BitmapData asset |
---|---|
bitmapData | The matching BitmapData instance |