springroll.AssetLoad Class

Class that represents a single multi load

Constructor

springroll.AssetLoad

(
  • manager
)
private

Parameters:

addTask

(
  • asset
)
private

Defined in addTask:338

Load a single asset

Parameters:

  • asset Object

    The asset to load, can either be an object, URL/path, or async function.

addTasks

(
  • assets
)
private

Defined in addTasks:241

Create a list of tasks from assets

Parameters:

applyDefaults

(
  • asset
)
Object
private static

Defined in applyDefaults:311

Convert assets into object defaults

Parameters:

  • asset

    The function to convert

Returns:

Object:

The object asset to use

destroy

()

Inherited from springroll.EventDispatcher but overwritten in destroy:538

Destroy this and discard

getAssetsContainer

(
  • mode
)
Array | Object | Null
private

Get an empty assets collection

Parameters:

  • mode Int

    The mode

Returns:

Array | Object | Null:

Empty container for assets

getTaskByAsset

(
  • asset
)
Function
private static

Defined in getTaskByAsset:370

Get the Task definition for an asset

Parameters:

  • asset Object

    The asset to check

Returns:

Function:

The Task class

has

(
  • name
  • [callback]
)
Boolean

Checks if the EventDispatcher has a specific listener or any listener for a given event.

Parameters:

  • name String

    The name of the single event type to check for

  • [callback] Function optional

    The listener function to check for. If omitted, checks for any listener.

Returns:

Boolean:

If the EventDispatcher has the specified listener.

isFunction

(
  • obj
)
Boolean
private

Defined in isFunction:562

Check if an object is an function type

Parameters:

  • obj

    The object

Returns:

Boolean:

If it's an function

isString

(
  • obj
)
Boolean
private

Defined in isString:550

Check if an object is an String type

Parameters:

  • obj

    The object

Returns:

Boolean:

If it's an String

nextTask

()
private

Defined in nextTask:396

Run the next task that's waiting

off

(
  • name
  • callback
)
EventDispatcher

Remove the event listener

Parameters:

  • name String*

    The type of event string separated by spaces, if no name is specifed remove all listeners.

  • callback Function | Array*

    The listener function or collection of callback functions

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

on

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Add an event listener. The parameters for the listener functions depend on the event.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

once

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Add an event listener but only handle it one time.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

reset

()

Defined in reset:188

Set back to the original state

setup

(
  • assets
  • [options]
)

Defined in setup:144

Initialize the Load

Parameters:

  • assets Object | Array

    The collection of assets to load

  • [options] Object optional

    The loading options

    • [startAll=true] Boolean optional

      If we should run the tasks in order

    • [autoStart=true] Boolean optional

      Automatically start running

    • [cacheAll=false] Boolean optional

      If we should run the tasks in order

    • [type] String optional

      The default asset type of load, gets attached to each asset

start

()

Defined in start:174

Start the load process

taskDone

(
  • task
  • [result]
)
private

Defined in taskDone:418

Handler when a task has completed

Parameters:

  • task springroll.Task

    Reference to original task

  • [result] optional

    The result of load

toString

()

Defined in toString:134

Debugging purposes

trigger

(
  • type
  • arguments
)

Dispatch an event

Parameters:

  • type String

    The type of event to trigger

  • arguments

    Additional parameters for the listener functions.

type

(
  • value
)
String
private

Return type of the value.

Parameters:

  • value

Returns:

String:

The type

_destroyed

Boolean protected

If the dispatcher is destroyed

_listeners

Object private

The collection of listeners

cacheAll

Boolean

Defined in cacheAll:53

If we should try to cache all items in the load

Default: false

destroyed

Boolean

If the dispatcher is destroyed

ID

Int private static

Defined in ID:126

Debugging Keep track of how many we've created

LIST_MODE

Int private final static

Defined in LIST_MODE:231

The result is an array of result objects

Default: 2

manager

springroll.AssetManager

Defined in manager:28

Reference to the Task Manager

MAP_MODE

Int private final static

Defined in MAP_MODE:221

The result is a map of result objects

Default: 1

mode

Int

Defined in mode:39

How to display the results, either as single (0), map (1) or list (2)

Default: 1

numLoaded

Int

Defined in numLoaded:79

The total number of assets loaded

Default: 0

results

Array | Object

Defined in results:66

The results to return when we're done

running

Boolean

Defined in running:72

If the load is currently running

Default: false

SINGLE_MODE

Int private final static

Defined in SINGLE_MODE:211

The result is a single result

Default: 0

startAll

Boolean

Defined in startAll:46

If we should run the tasks in parallel (true) or serial (false)

Default: true

tasks

Array

Defined in tasks:60

The list of tasks to load

total

Int

Defined in total:86

The total number of assets

Default: 0

type

String

Defined in type:93

The default asset type if not defined

Default: null

complete

Defined in complete:112

When all assets have been completed loaded

Event Payload:

progress

Defined in progress:118

Check how many assets have finished loaded

Event Payload:

  • percentage Number

    The amount loaded from 0 to 1

taskDone

Defined in taskDone:104

When an asset is finished

Event Payload:

  • result

    The loader result

  • originalAsset Object

    The original load asset

  • assets Array

    Collection to add additional assets to