class lime.Assets

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.

Class Fields

static var cache:AssetCache

static var onChange:Event_Void_Void<Void ->Void>

static function exists(id:String, ?type:AssetType): Bool

static function getAudioBuffer(id:String, ?useCache:Bool): AudioBuffer

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

id

The ID or asset path for the sound

returns

A new Sound object

static function getBytes(id:String): Bytes

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

id

The ID or asset path for the file

returns

A new Bytes object

static function getFont(id:String, ?useCache:Bool): Font

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

id

The ID or asset path for the font

returns

A new Font object

static function getImage(id:String, ?useCache:Bool): Image

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

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

static function getPath(id:String): String

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

id

The ID or asset path for the asset

returns

The path to the asset (or null)

static function getText(id:String): String

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

id

The ID or asset path for the file

returns

A new String object

static function isLocal(id:String, ?type:AssetType, ?useCache:Bool): Bool

static function list(?type:AssetType): Array<String>

static function loadAudioBuffer(id:String, ?useCache:Bool): Future<AudioBuffer>

static function loadBytes(id:String): Future<Bytes>

static function loadFont(id:String): Future<Font>

static function loadImage(id:String, ?useCache:Bool): Future<Image>

static function loadLibrary(name:String): Future<AssetLibrary>

static function loadText(id:String): Future<String>

static function registerLibrary(name:String, library:AssetLibrary): Void

static function unloadLibrary(name:String): Void