A system for loading assets in an organized manner.

Constructor

new ()

Variables

read onlycomplete:Bool = false

Whether or not all tasks are complete (new tasks can still be created).

read onlyprogress:Float = 0

Percentage of tasks that have been completed.

onComplete:Void ‑> Void

Callback for when all tasks are complete.

onProgress:Void ‑> Void

Callback for when progress is made.

Methods

createTask (task:Int ‑> Void):Void

Creates a new task, which is a callback that receives an ID.

Parameters:

task

Callback for when the task is started.

endTask (id:Int):Void

Marks the task with the specifified ID as finished.

Parameters:

id

ID of the task.

loadFonts (config:Dynamic, ?onLoad:Void ‑> Void, ?onError:Void ‑> Void):Void

Loads fonts using Google's web font loader.

Parameters:

config

The configuration for the font loader.

onLoad

Callback for when the fonts load.

onError

Callback for when the fonts couldn't load.

loadHowl (options:HowlOptions, ?onLoad:Howl ‑> Void, ?onError:Void ‑> Void):Howl

Loads sounds for use with Howler.js.

Parameters:

options

The Howler options for the sound.

onLoad

Callback for when the sound loads.

onError

Callback for when the sound couldn't load.

loadImage (path:String, ?onLoad:Image ‑> Void, ?onError:Void ‑> Void):Image

Loads an image from the specified path. The returned image is usable once it loads.

Parameters:

path

Path to the image.

onLoad

Callback for when the image loads.

onError

Callback for when the image couldn't load.

loadText (path:String, onLoad:String ‑> Void, ?onError:Void ‑> Void):Dynamic

Loads text from the specified path. Returns null, so store the string you receive from the onLoad callback.

Parameters:

path

Path to the text file.

onLoad

Callback for when the text loads.

onError

Callback for when the text couldn't load.

start ():Void

Starts the tasks, triggering the loading of any assets.