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 Lime command-line tools, based on the contents of the 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.

Static variables

@:value(new AssetCache())staticcache:AssetCache = new AssetCache()

@:value(new Event<Void>())staticonChange:_Event_Void_Void<() ‑> Void> = new Event<Void>()

Static methods

@:value({ type : null })staticexists(id:String, ?type:AssetType):Bool

staticgetAsset(id:String, type:AssetType, useCache:Bool):Dynamic

Gets an instance of a cached or embedded asset @usage var sound = Assets.getAsset("sound.wav", SOUND);

Parameters:

id

The ID or asset path for the asset

Returns:

An Asset object, or null.

@:value({ useCache : true })staticgetAudioBuffer(id:String, useCache:Bool = true):AudioBuffer

Gets an instance of an embedded sound @usage var sound = Assets.getAudioBuffer ("sound.wav");

Parameters:

id

The ID or asset path for the sound

Returns:

A new Sound object

staticgetBytes(id:String):Bytes

Gets an instance of an embedded binary asset @usage var bytes = Assets.getBytes("file.zip");

Parameters:

id

The ID or asset path for the file

Returns:

A new Bytes object

@:value({ useCache : true })staticgetFont(id:String, useCache:Bool = true):Font

Gets an instance of an embedded font @usage var fontName = Assets.getFont("font.ttf").fontName;

Parameters:

id

The ID or asset path for the font

Returns:

A new Font object

@:value({ useCache : true })staticgetImage(id:String, useCache:Bool = true):Image

Gets an instance of an embedded bitmap @usage var bitmap = new Bitmap(Assets.getBitmapData("image.jpg"));

Parameters:

id

The ID or asset path for the bitmap

useCache

(Optional) Whether to use BitmapData from the cache(Default: true)

Returns:

A new BitmapData object

staticgetPath(id:String):String

Gets the file path (if available) for an asset @usage var path = Assets.getPath("image.jpg");

Parameters:

id

The ID or asset path for the asset

Returns:

The path to the asset (or null)

staticgetText(id:String):String

Gets an instance of an embedded text asset @usage var text = Assets.getText("text.txt");

Parameters:

id

The ID or asset path for the file

Returns:

A new String object

statichasLibrary(name:String):Bool

@:value({ useCache : true, type : null })staticisLocal(id:String, ?type:AssetType, useCache:Bool = true):Bool

@:has_untyped@:value({ type : null })staticlist(?type:AssetType):Array<String>

staticloadAsset(id:String, type:AssetType, useCache:Bool):Future<Dynamic>

@:value({ useCache : true })staticloadAudioBuffer(id:String, useCache:Bool = true):Future<AudioBuffer>

@:value({ useCache : true })staticloadFont(id:String, useCache:Bool = true):Future<Font>

@:value({ useCache : true })staticloadImage(id:String, useCache:Bool = true):Future<Image>