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
Static methods
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.
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
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