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 *.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.

Static variables

staticcache:AssetCache = new AssetCache()

staticread onlylibraries:Map<String, AssetLibrary> = new Map<String,AssetLibrary>()

staticonChange:Event_Void_Void<Void‑>Void> = new Event<Void>()

Static methods

staticexists(id:String, ?type:AssetType):Bool

staticgetAudioBuffer(id:String, useCache:Bool = true):AudioBuffer

Gets an instance of an embedded sound @usage var sound = Assets.getSound("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

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

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

staticisLocal(id:String, ?type:AssetType, useCache:Bool = true):Bool

staticlist(?type:AssetType):Array<String>

staticloadAudioBuffer(id:String, useCache:Bool = true):Future<AudioBuffer>

staticloadImage(id:String, useCache:Bool = true):Future<Image>