Loads binary data from a local or remote URL with a very simple callback system.

The DataLoader is used by the AssetManager to load any local or remote data. Its single purpose is to get the binary data that's stored at a specific URL.

You can use this class for your own purposes (as an easier to use 'URLLoader' alternative), or you can extend the class to modify the AssetManager's behavior. E.g. you could extend this class to add a caching mechanism for remote assets. Assign an instance of your extended class to the AssetManager's `dataLoader` property.

### Hierarchy

- DataLoader

## Index

### Constructors

- constructor

### Methods

- close
- load

## Constructors

### constructor

- new DataLoader(): DataLoader

- - Defined in lib/starling/assets/DataLoader.d.ts:27

  Creates a new DataLoader instance.

  #### Returns DataLoader

## Methods

### close

- close(): void

- - Defined in lib/starling/assets/DataLoader.d.ts:52

  Aborts all current load operations. The loader can still be used, though.

  #### Returns void

### load

- load(url: string, onComplete: function, onError: function, onProgress?: function): void

- - Defined in lib/starling/assets/DataLoader.d.ts:48

  Loads the binary data from a specific URL. Always supply both 'onComplete' and 'onError' parameters; in case of an error, only the latter will be called.

  The 'onComplete' callback may have up to four parameters, all of them being optional. If you pass a callback that just takes zero or one, it will work just as well. The additional parameters may be used to describe the name and type of the downloaded data. They are not provided by the base class, but the AssetManager will check if they are available.

  #### Parameters

  - ##### url: string

    a String containing an URL.

  - ##### onComplete: function

    will be called when the data has been loaded. `function(data:ByteArray, mimeType:string, name:string, extension:string):void`

    - - (data?: ByteArray, mimeType?: string, name?: string, extension?: string): void

      - #### Parameters

        - ##### Optional data: ByteArray

        - ##### Optional mimeType: string

        - ##### Optional name: string

        - ##### Optional extension: string

        #### Returns void

  - ##### onError: function

    will be called in case of an error. The 2nd parameter is optional. `function(error:string, httpStatus:number):void`

    - - (string: any): void

      - #### Parameters

        - ##### string: any

        #### Returns void

  - ##### Optional onProgress: function

    will be called multiple times with the current load ratio (0-1). `function(ratio:Number):void`

    - - (number: any): void

      - #### Parameters

        - ##### number: any

        #### Returns void

Generated using TypeDoc