The Assets class provides a cross-platform interface to access embedded images, fonts, sounds and other resource files.

The contents are populated automatically when an application is compiled using the OpenFL command-line tools, based on the contents of the *.xml project file.

For most platforms, the assets are included in the same directory or package as the application, and the paths are handled automatically. For web content, the assets are preloaded before the start of the rest of the application. You can customize the preloader by extending the `NMEPreloader` class, and specifying a custom preloader using in the project file.

### Hierarchy

- Assets

## Index

### Properties

- cache

### Methods

- addEventListener
- dispatchEvent
- exists
- getBitmapData
- getBytes
- getFont
- getLibrary
- getMovieClip
- getPath
- getSound
- getText
- hasEventListener
- hasLibrary
- isLocal
- list
- loadBitmapData
- loadBytes
- loadFont
- loadLibrary
- loadMovieClip
- loadMusic
- loadSound
- loadText
- registerLibrary
- removeEventListener
- unloadLibrary

## Properties

### Static cache

cache: IAssetCache

- Defined in lib/openfl/utils/Assets.d.ts:36

## Methods

### Static addEventListener

- addEventListener(type: string, listener: any, useCapture?: boolean, priority?: number, useWeakReference?: boolean): void

- - Defined in lib/openfl/utils/Assets.d.ts:38

  #### Parameters

  - ##### type: string

  - ##### listener: any

  - ##### Optional useCapture: boolean

  - ##### Optional priority: number

  - ##### Optional useWeakReference: boolean

  #### Returns void

### Static dispatchEvent

- dispatchEvent(event: Event): boolean

- - Defined in lib/openfl/utils/Assets.d.ts:39

  #### Parameters

  - ##### event: Event

  #### Returns boolean

### Static exists

- exists(id: string, type?: AssetType): boolean

- - Defined in lib/openfl/utils/Assets.d.ts:47

  Returns whether a specific asset exists

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  - ##### Optional type: AssetType

    The asset type to match, or null to match any type

  #### Returns boolean

  Whether the requested asset ID and type exists

### Static getBitmapData

- getBitmapData(id: string, useCache?: boolean): BitmapData

- - Defined in lib/openfl/utils/Assets.d.ts:56

  Gets an instance of an embedded bitmap

  usage

    bitmap = new Bitmap (Assets.getBitmapData ("image.png"));

  #### Parameters

  - ##### id: string

    The ID or asset path for the bitmap

  - ##### Optional useCache: boolean

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns BitmapData

  A new BitmapData object

### Static getBytes

- getBytes(id: string): ByteArray

- - Defined in lib/openfl/utils/Assets.d.ts:64

  Gets an instance of an embedded binary asset

  usage

    bytes = Assets.getBytes ("file.zip");

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  #### Returns ByteArray

  A new ByteArray object

### Static getFont

- getFont(id: string, useCache?: boolean): Font

- - Defined in lib/openfl/utils/Assets.d.ts:73

  Gets an instance of an embedded font

  usage

    fontName = Assets.getFont ("font.ttf").fontName;

  #### Parameters

  - ##### id: string

    The ID or asset path for the font

  - ##### Optional useCache: boolean

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns Font

  A new Font object

### Static getLibrary

- getLibrary(name: string): LimeAssetLibrary

- - Defined in lib/openfl/utils/Assets.d.ts:75

  #### Parameters

  - ##### name: string

  #### Returns LimeAssetLibrary

### Static getMovieClip

- getMovieClip(id: string): MovieClip

- - Defined in lib/openfl/utils/Assets.d.ts:83

  Gets an instance of an included MovieClip

  usage

    movieClip = Assets.getMovieClip ("library:BouncingBall");

  #### Parameters

  - ##### id: string

    The ID for the MovieClip

  #### Returns MovieClip

  A new MovieClip object

### Static getPath

- getPath(id: string): string

- - Defined in lib/openfl/utils/Assets.d.ts:91

  Gets the file path (if available) for an asset

  usage

    path = Assets.getPath ("file.txt");

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  #### Returns string

  The path to the asset, or null if it does not exist

### Static getSound

- getSound(id: string, useCache?: boolean): Sound

- - Defined in lib/openfl/utils/Assets.d.ts:100

  Gets an instance of an embedded sound

  usage

    sound = Assets.getSound ("sound.wav");

  #### Parameters

  - ##### id: string

    The ID or asset path for the sound

  - ##### Optional useCache: boolean

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns Sound

  A new Sound object

### Static getText

- getText(id: string): string

- - Defined in lib/openfl/utils/Assets.d.ts:108

  Gets an instance of an embedded text asset

  usage

    text = Assets.getText ("text.txt");

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  #### Returns string

  A new String object

### Static hasEventListener

- hasEventListener(type: string): boolean

- - Defined in lib/openfl/utils/Assets.d.ts:110

  #### Parameters

  - ##### type: string

  #### Returns boolean

### Static hasLibrary

- hasLibrary(name: string): boolean

- - Defined in lib/openfl/utils/Assets.d.ts:111

  #### Parameters

  - ##### name: string

  #### Returns boolean

### Static isLocal

- isLocal(id: string, type?: AssetType, useCache?: boolean): boolean

- - Defined in lib/openfl/utils/Assets.d.ts:120

  Returns whether an asset is "local", and therefore can be loaded synchronously

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  - ##### Optional type: AssetType

    The asset type to match, or null to match any type

  - ##### Optional useCache: boolean

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns boolean

  Whether the asset is local

### Static list

- list(type?: AssetType): Array<String>

- - Defined in lib/openfl/utils/Assets.d.ts:127

  Returns a list of all embedded assets (by type)

  #### Parameters

  - ##### Optional type: AssetType

    The asset type to match, or null to match any type

  #### Returns Array<String>

  An array of asset ID values

### Static loadBitmapData

- loadBitmapData(id: string, useCache?: boolean | null): Future<BitmapData>

- - Defined in lib/openfl/utils/Assets.d.ts:137

  Loads an included bitmap asset asynchronously

  usage

    Assets.loadBitmapData ("image.png").onComplete (handleImage);

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  - ##### Optional useCache: boolean | null

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns Future<BitmapData>

  Returns a Future

### Static loadBytes

- loadBytes(id: string): Future<ByteArray>

- - Defined in lib/openfl/utils/Assets.d.ts:147

  Loads an included byte asset asynchronously

  usage

    Assets.loadBytes ("file.zip").onComplete (handleBytes);

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  #### Returns Future<ByteArray>

  Returns a Future

### Static loadFont

- loadFont(id: string, useCache?: boolean | null): Future<Font>

- - Defined in lib/openfl/utils/Assets.d.ts:157

  Loads an included font asset asynchronously

  usage

    Assets.loadFont ("font.ttf").onComplete (handleFont);

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  - ##### Optional useCache: boolean | null

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns Future<Font>

  Returns a Future

### Static loadLibrary

- loadLibrary(name: string): Future<LimeAssetLibrary>

- - Defined in lib/openfl/utils/Assets.d.ts:165

  Load an included AssetLibrary

  #### Parameters

  - ##### name: string

    The name of the AssetLibrary to load

  #### Returns Future<LimeAssetLibrary>

  Returns a Future

### Static loadMovieClip

- loadMovieClip(id: string): Future<MovieClip>

- - Defined in lib/openfl/utils/Assets.d.ts:185

  Loads an included MovieClip asset asynchronously

  usage

    Assets.loadMovieClip ("library:BouncingBall").onComplete (handleMovieClip);

  #### Parameters

  - ##### id: string

    The ID for the asset

  #### Returns Future<MovieClip>

  Returns a Future

### Static loadMusic

- loadMusic(id: string, useCache?: boolean | null): Future<Sound>

- - Defined in lib/openfl/utils/Assets.d.ts:175

  Loads an included music asset asynchronously

  usage

    Assets.loadMusic ("music.ogg").onComplete (handleMusic);

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  - ##### Optional useCache: boolean | null

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns Future<Sound>

  Returns a Future

### Static loadSound

- loadSound(id: string, useCache?: boolean | null): Future<Sound>

- - Defined in lib/openfl/utils/Assets.d.ts:195

  Loads an included sound asset asynchronously

  usage

    Assets.loadSound ("sound.wav").onComplete (handleSound);

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  - ##### Optional useCache: boolean | null

    (Optional) Whether to allow use of the asset cache (Default: true)

  #### Returns Future<Sound>

  Returns a Future

### Static loadText

- loadText(id: string): Future<String>

- - Defined in lib/openfl/utils/Assets.d.ts:205

  Loads an included text asset asynchronously

  usage

    Assets.loadText ("text.txt").onComplete (handleString);

  #### Parameters

  - ##### id: string

    The ID or asset path for the asset

  #### Returns Future<String>

  Returns a Future

### Static registerLibrary

- registerLibrary(name: string, library: AssetLibrary): void

- - Defined in lib/openfl/utils/Assets.d.ts:212

  Registers a new AssetLibrary with the Assets class

  #### Parameters

  - ##### name: string

    The name (prefix) to use for the library

  - ##### library: AssetLibrary

    An AssetLibrary instance to register

  #### Returns void

### Static removeEventListener

- removeEventListener(type: string, listener: any, capture?: boolean): void

- - Defined in lib/openfl/utils/Assets.d.ts:214

  #### Parameters

  - ##### type: string

  - ##### listener: any

  - ##### Optional capture: boolean

  #### Returns void

### Static unloadLibrary

- unloadLibrary(name: string): void

- - Defined in lib/openfl/utils/Assets.d.ts:215

  #### Parameters

  - ##### name: string

  #### Returns void

Generated using TypeDoc