import IAssetCache from "./IAssetCache";
import Future from "./Future";
import ByteArray from "./ByteArray";
import AssetType from "./AssetType";
import AssetLibrary from "./AssetLibrary";
import Font from "../text/Font";
import Sound from "../media/Sound";
import Event from "../events/Event";
import MovieClip from "../display/MovieClip";
import BitmapData from "../display/BitmapData";
declare namespace openfl.utils {
/**
* 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.
*
* @see [Working with bitmap assets](https://books.openfl.org/openfl-developers-guide/working-with-bitmaps/working-with-bitmap-assets.html)
* @see [Working with byte array assets](https://books.openfl.org/openfl-developers-guide/working-with-byte-arrays/working-with-byte-array-assets.html)
* @see [Working with font assets](https://books.openfl.org/openfl-developers-guide/using-the-textfield-class/working-with-font-assets.html)
* @see [Working with sound assets](https://books.openfl.org/openfl-developers-guide/working-with-sound/working-with-sound-assets.html)
*
*/
export class Assets {
static cache: IAssetCache;
static addEventListener(type: string, listener: any, useCapture?: boolean, priority?: number, useWeakReference?: boolean): void;
static dispatchEvent(event: Event): boolean;
/**
* Returns whether a specific asset exists
* @param id The ID or asset path for the asset
* @param type The asset type to match, or null to match any type
* @return Whether the requested asset ID and type exists
*
*/
static exists(id: string, type?: AssetType): boolean;
/**
* Gets an instance of an embedded bitmap.
*
* ```haxe
* var bitmap = new Bitmap (Assets.getBitmapData ("image.png"));
* ```
*
* _Note:_ This method may behave differently, depending on the target
* platform. On targets that can quickly create new BitmapData instances
* synchronously, every call to `Assets.getBitmapData()` with the same ID
* will return a BitmapData instance with its own separate copy of the
* underlying image data. However, on other targets where loading
* BitmapData synchronously is unacceptably slow, or where BitmapData may
* not be loaded synchronously at all (meaning that there is no choice but
* to load it asynchronously), every call to `Assets.getBitmapData()` with
* the same ID may return a BitmapData instance that shares the same
* underlying image data each time.
*
* With that in mind, modifying or disposing the contents of the BitmapData
* returned by `Assets.getBitmapData()` may affect the results of future
* calls to `Assets.getBitmapData()` on some targets. To access a
* BitmapData instance that may be modified or disposed without affecting
* future calls to `Assets.getBitmapData()`, call the BitmapData instance's
* `clone()` method to manually create a copy.
*
* @param id The ID or asset path for the bitmap
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return A new BitmapData object
*
* @see [Working with bitmap assets](https://books.openfl.org/openfl-developers-guide/working-with-bitmaps/working-with-bitmap-assets.html)
*
*/
static getBitmapData(id: string, useCache?: boolean): BitmapData;
/**
* Gets an instance of an embedded binary asset
*
* ```haxe
* var bytes = Assets.getBytes ("file.zip");
* ```
*
* @param id The ID or asset path for the asset
* @return A new ByteArray object
*
* @see [Working with byte array assets](https://books.openfl.org/openfl-developers-guide/working-with-byte-arrays/working-with-byte-array-assets.html)
*
*/
static getBytes(id: string): ByteArray;
/**
* Gets an instance of an embedded font
*
* ```haxe
* var fontName = Assets.getFont ("font.ttf").fontName;
* ```
*
* @param id The ID or asset path for the font
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return A new Font object
*
* @see [Working with font assets](https://books.openfl.org/openfl-developers-guide/using-the-textfield-class/working-with-font-assets.html)
*
*/
static getFont(id: string, useCache?: boolean): Font;
static getLibrary(name: string): any;
/**
* Gets an instance of an included MovieClip
*
* ```haxe
* var movieClip = Assets.getMovieClip ("library:BouncingBall");
* ```
*
* @param id The ID for the MovieClip
* @return A new MovieClip object
*
*/
static getMovieClip(id: string): MovieClip;
static getMusic(id: string, useCache?: boolean): Sound;
/**
* Gets the file path (if available) for an asset
*
* ```haxe
* var path = Assets.getPath ("file.txt");
* ```
*
* @param id The ID or asset path for the asset
* @return The path to the asset, or null if it does not exist
*
*/
static getPath(id: string): string;
/**
* Gets an instance of an embedded sound
*
* ```haxe
* var sound = Assets.getSound ("sound.wav");
* ```
*
* @param id The ID or asset path for the sound
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return A new Sound object
*
* @see [Working with sound assets](https://books.openfl.org/openfl-developers-guide/working-with-sound/working-with-sound-assets.html)
*
*/
static getSound(id: string, useCache?: boolean): Sound;
/**
* Gets an instance of an embedded text asset
*
* ```haxe
* var text = Assets.getText ("text.txt");
* ```
*
* @param id The ID or asset path for the asset
* @return A new String object
*
*/
static getText(id: string): string;
static hasEventListener(type: string): boolean;
static hasLibrary(name: string): boolean;
/**
* Connects a user-defined class to a related asset class.
*
* This method call is added to the beginning of user-defined class constructors when
* the `@:bind` meta-data is used. This allows insertion of related asset resources in
* compatible super classes, such as `openfl.display.MovieClip`.
* @param className The registered class name of the asset constructor
* @param instance The current class instance to be bound (default is null)
* @return Whether asset binding was successful
*
*/
static initBinding(className: string, instance?: any): void;
/**
* Returns whether an asset is "local", and therefore can be loaded synchronously
* @param id The ID or asset path for the asset
* @param type The asset type to match, or null to match any type
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return Whether the asset is local
*
*/
static isLocal(id: string, type?: AssetType, useCache?: boolean): boolean;
/**
* Returns a list of all embedded assets (by type)
* @param type The asset type to match, or null to match any type
* @return An array of asset ID values
*
*/
static list(type?: AssetType): Array;
/**
* Loads an included bitmap asset asynchronously
*
* ```haxe
* Assets.loadBitmapData ("image.png").onComplete (handleImage);
* ```
*
* @param id The ID or asset path for the asset
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return Returns a Future
*
* @see [Working with bitmap assets](https://books.openfl.org/openfl-developers-guide/working-with-bitmaps/working-with-bitmap-assets.html)
*
*/
static loadBitmapData(id: string, useCache?: boolean): Future;
/**
* Loads an included byte asset asynchronously
*
* ```haxe
* Assets.loadBytes ("file.zip").onComplete (handleBytes);
* ```
*
* @param id The ID or asset path for the asset
* @return Returns a Future
*
* @see [Working with byte array assets](https://books.openfl.org/openfl-developers-guide/working-with-byte-arrays/working-with-byte-array-assets.html)
*
*/
static loadBytes(id: string): Future;
/**
* Loads an included font asset asynchronously
*
* ```haxe
* Assets.loadFont ("font.ttf").onComplete (handleFont);
* ```
*
* @param id The ID or asset path for the asset
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return Returns a Future
*
* @see [Working with font assets](https://books.openfl.org/openfl-developers-guide/using-the-textfield-class/working-with-font-assets.html)
*
*/
static loadFont(id: string, useCache?: boolean): Future;
/**
* Load an included AssetLibrary
* @param name The name of the AssetLibrary to load
* @return Returns a Future
*
*/
static loadLibrary(name: string): Future;
/**
* Loads an included music asset asynchronously
*
* ```haxe
* Assets.loadMusic ("music.ogg").onComplete (handleMusic);
* ```
*
* @param id The ID or asset path for the asset
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return Returns a Future
*
*/
static loadMusic(id: string, useCache?: boolean): Future;
/**
* Loads an included MovieClip asset asynchronously
*
* ```haxe
* Assets.loadMovieClip ("library:BouncingBall").onComplete (handleMovieClip);
* ```
*
* @param id The ID for the asset
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return Returns a Future
*
*/
static loadMovieClip(id: string): Future;
/**
* Loads an included sound asset asynchronously
*
* ```haxe
* Assets.loadSound ("sound.wav").onComplete (handleSound);
* ```
*
* @param id The ID or asset path for the asset
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return Returns a Future
*
* @see [Working with sound assets](https://books.openfl.org/openfl-developers-guide/working-with-sound/working-with-sound-assets.html)
*
*/
static loadSound(id: string, useCache?: boolean): Future;
/**
* Loads an included text asset asynchronously
*
* ```haxe
* Assets.loadText ("text.txt").onComplete (handleString);
* ```
*
* @param id The ID or asset path for the asset
* @param useCache (Optional) Whether to allow use of the asset cache (Default: true)
* @return Returns a Future
*
*/
static loadText(id: string): Future;
/**
* Registers an AssetLibrary binding for use with @:bind or Assets.bind
* @param className The class name to use for the binding
* @param method The AssetLibrary responsible for the binding
*
*/
static registerBinding(className: string, library: AssetLibrary): void;
/**
* Registers a new AssetLibrary with the Assets class
* @param name The name (prefix) to use for the library
* @param library An AssetLibrary instance to register
*
*/
static registerLibrary(name: string, library: AssetLibrary): void;
static removeEventListener(type: string, listener: any, capture?: boolean): void;
static unloadLibrary(name: string): void;
/**
* Unregisters an AssetLibrary binding for use with @:bind or Assets.bind
* @param className The class name to use for the binding
* @param method The AssetLibrary responsible for the binding
*
*/
static unregisterBinding(className: string, library: AssetLibrary): void;
}
}
export default openfl.utils.Assets;