| |
|---|
| Kind | class |
| Package | openfl.utils |
| Full name | openfl.utils.Assets |
| Source | source/source-haxelib-patches/openfl/utils/Assets.hx |
| Metadata | @:fileXml('tags="haxe,release"') @:noDebug @:access(openfl.display.BitmapData) @:access(openfl.display.Sprite) @:access(openfl.text.Font) @:access(openfl.utils.AssetLibrary) |
Public fields
| Name | Type | Static | Default | Notes |
|---|
cache | IAssetCache | yes | new AssetCache() | — |
Public methods
addEventListener
static function addEventListener(type:String, listener:Dynamic, useCapture:Bool = false, priority:Int = 0, useWeakReference:Bool = false):Void
| Parameter | Type | Default |
|---|
type | String | — |
listener | Dynamic | — |
useCapture (optional) | Bool | false |
priority (optional) | Int | 0 |
useWeakReference (optional) | Bool | false |
View source
dispatchEvent
static function dispatchEvent(event:Event):Bool
| Parameter | Type | Default |
|---|
event | Event | — |
View source
exists
static function exists(id:String, type:AssetType = null):Bool
Returns whether a specific asset exists
@param id The ID or asset path for the asset
@param type The asset type to match, or null to match any type
@return Whether the requested asset ID and type exists
| Parameter | Type | Default |
|---|
id | String | — |
type (optional) | AssetType | null |
View source
getBitmapData
static function getBitmapData(id:String, useCache:Bool = true):BitmapData
Gets an instance of an embedded bitmap
@usage var bitmap = new Bitmap (Assets.getBitmapData ("image.png"));
@param id The ID or asset path for the bitmap
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return A new BitmapData object
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Bool | true |
View source
getBytes
static function getBytes(id:String):ByteArray
Gets an instance of an embedded binary asset
@usage var bytes = Assets.getBytes ("file.zip");
@param id The ID or asset path for the asset
@return A new ByteArray object
| Parameter | Type | Default |
|---|
id | String | — |
View source
getFont
static function getFont(id:String, useCache:Bool = true):Font
Gets an instance of an embedded font
@usage var fontName = Assets.getFont ("font.ttf").fontName;
@param id The ID or asset path for the font
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return A new Font object
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Bool | true |
View source
getLibrary
static function getLibrary(name:String):#if lime LimeAssetLibrary #else AssetLibrary #end
| Parameter | Type | Default |
|---|
name | String | — |
View source
getMovieClip
static function getMovieClip(id:String):MovieClip
Gets an instance of an included MovieClip
@usage var movieClip = Assets.getMovieClip ("library:BouncingBall");
@param id The ID for the MovieClip
@return A new MovieClip object
| Parameter | Type | Default |
|---|
id | String | — |
View source
getMusic
static function getMusic(id:String, useCache:Bool = true):Sound
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Bool | true |
View source
getPath
static function getPath(id:String):String
Gets the file path (if available) for an asset
@usage var path = Assets.getPath ("file.txt");
@param id The ID or asset path for the asset
@return The path to the asset, or null if it does not exist
| Parameter | Type | Default |
|---|
id | String | — |
View source
getSound
static function getSound(id:String, useCache:Bool = true):Sound
Gets an instance of an embedded sound
@usage var sound = Assets.getSound ("sound.wav");
@param id The ID or asset path for the sound
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return A new Sound object
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Bool | true |
View source
getText
static function getText(id:String):String
Gets an instance of an embedded text asset
@usage var text = Assets.getText ("text.txt");
@param id The ID or asset path for the asset
@return A new String object
| Parameter | Type | Default |
|---|
id | String | — |
View source
hasEventListener
static function hasEventListener(type:String):Bool
| Parameter | Type | Default |
|---|
type | String | — |
View source
hasLibrary
static function hasLibrary(name:String):Bool
| Parameter | Type | Default |
|---|
name | String | — |
View source
initBinding
static function initBinding(className:String, instance:Dynamic = null):Void
Connects a user-defined class to a related asset class.
This method call is added to the beginning of user-defined class constructors when
the `@:bind` meta-data is used. This allows insertion of related asset resources in
compatible super classes, such as `openfl.display.MovieClip`.
@param className The registered class name of the asset constructor
@param instance The current class instance to be bound (default is null)
@return Whether asset binding was successful
| Parameter | Type | Default |
|---|
className | String | — |
instance (optional) | Dynamic | null |
View source
isLocal
static function isLocal(id:String, type:AssetType = null, useCache:Bool = true):Bool
Returns whether an asset is "local", and therefore can be loaded synchronously
@param id The ID or asset path for the asset
@param type The asset type to match, or null to match any type
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return Whether the asset is local
| Parameter | Type | Default |
|---|
id | String | — |
type (optional) | AssetType | null |
useCache (optional) | Bool | true |
View source
list
static function list(type:AssetType = null):Array<String>
Returns a list of all embedded assets (by type)
@param type The asset type to match, or null to match any type
@return An array of asset ID values
| Parameter | Type | Default |
|---|
type (optional) | AssetType | null |
View source
loadBitmapData
static function loadBitmapData(id:String, useCache:Null<Bool> = true):Future<BitmapData>
Loads an included bitmap asset asynchronously
@usage Assets.loadBitmapData ("image.png").onComplete (handleImage);
@param id The ID or asset path for the asset
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return Returns a Future<BitmapData>
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Null<Bool> | true |
View source
loadBytes
static function loadBytes(id:String):Future<ByteArray>
Loads an included byte asset asynchronously
@usage Assets.loadBytes ("file.zip").onComplete (handleBytes);
@param id The ID or asset path for the asset
@return Returns a Future<ByteArray>
| Parameter | Type | Default |
|---|
id | String | — |
View source
loadFont
static function loadFont(id:String, useCache:Null<Bool> = true):Future<Font>
Loads an included font asset asynchronously
@usage Assets.loadFont ("font.ttf").onComplete (handleFont);
@param id The ID or asset path for the asset
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return Returns a Future<Font>
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Null<Bool> | true |
View source
loadLibrary
static function loadLibrary(name:String):#if java Future<LimeAssetLibrary> #else Future<AssetLibrary> #end
Load an included AssetLibrary
@param name The name of the AssetLibrary to load
@return Returns a Future<AssetLibrary>
| Parameter | Type | Default |
|---|
name | String | — |
View source
loadMusic
static function loadMusic(id:String, useCache:Null<Bool> = true):Future<Sound>
Loads an included music asset asynchronously
@usage Assets.loadMusic ("music.ogg").onComplete (handleMusic);
@param id The ID or asset path for the asset
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return Returns a Future<Sound>
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Null<Bool> | true |
View source
loadMovieClip
static function loadMovieClip(id:String):Future<MovieClip>
Loads an included MovieClip asset asynchronously
@usage Assets.loadMovieClip ("library:BouncingBall").onComplete (handleMovieClip);
@param id The ID for the asset
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return Returns a Future<MovieClip>
| Parameter | Type | Default |
|---|
id | String | — |
View source
loadSound
static function loadSound(id:String, useCache:Null<Bool> = true):Future<Sound>
Loads an included sound asset asynchronously
@usage Assets.loadSound ("sound.wav").onComplete (handleSound);
@param id The ID or asset path for the asset
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return Returns a Future<Sound>
| Parameter | Type | Default |
|---|
id | String | — |
useCache (optional) | Null<Bool> | true |
View source
loadText
static function loadText(id:String):Future<String>
Loads an included text asset asynchronously
@usage Assets.loadText ("text.txt").onComplete (handleString);
@param id The ID or asset path for the asset
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@return Returns a Future<String>
| Parameter | Type | Default |
|---|
id | String | — |
View source
registerBinding
static function registerBinding(className:String, library:AssetLibrary):Void
Registers an AssetLibrary binding for use with @:bind or Assets.bind
@param className The class name to use for the binding
@param method The AssetLibrary responsible for the binding
| Parameter | Type | Default |
|---|
className | String | — |
library | AssetLibrary | — |
View source
registerLibrary
static function registerLibrary(name:String, library:AssetLibrary):Void
Registers a new AssetLibrary with the Assets class
@param name The name (prefix) to use for the library
@param library An AssetLibrary instance to register
| Parameter | Type | Default |
|---|
name | String | — |
library | AssetLibrary | — |
View source
removeEventListener
static function removeEventListener(type:String, listener:Dynamic, capture:Bool = false):Void
| Parameter | Type | Default |
|---|
type | String | — |
listener | Dynamic | — |
capture (optional) | Bool | false |
View source
unloadLibrary
static function unloadLibrary(name:String):Void
| Parameter | Type | Default |
|---|
name | String | — |
View source
unregisterBinding
static function unregisterBinding(className:String, library:AssetLibrary):Void
Unregisters an AssetLibrary binding for use with @:bind or Assets.bind
@param className The class name to use for the binding
@param method The AssetLibrary responsible for the binding
| Parameter | Type | Default |
|---|
className | String | — |
library | AssetLibrary | — |
View source
Internals
Private / internal members
| Field | Type | Static |
|---|
libraryBindings | Map<String, AssetLibrary> | yes |