MultiFile
A MultiFile is a composite file that groups two or more individual File objects as children and coordinates their loading and processing as a single unit. When all child files have loaded, the MultiFile's addToCache method is called to combine the results (e.g., associating a texture image with its JSON atlas data). It is commonly extended as a base class for file types such as AtlasJSON, BitmapFont, and AudioSprite. You should not create an instance directly, but extend it and override addToCache.
Constructor
new MultiFile(loader, type, key, files)
Parameters
| name | type | optional | description |
|---|---|---|---|
| loader | Phaser.Loader.LoaderPlugin | No | The Loader that is going to load this File. |
| type | string | No | The file type string for sorting within the Loader. |
| key | string | No | The key of the file within the loader. |
| files | Array.<Phaser.Loader.File> | No | An array of Files that make-up this MultiFile. |
Scope: static
Source: src/loader/MultiFile.js#L11
Since: 3.7.0
Public Members
baseURL
baseURL: string
Description:
A reference to the Loaders baseURL at the time this MultiFile was created. Used to populate child-files.
Source: src/loader/MultiFile.js#L150
Since: 3.20.0
complete
complete: boolean
Description:
The completion status of this MultiFile.
Source: src/loader/MultiFile.js#L109
Since: 3.7.0
config
config: any
Description:
A storage container for transient data that the loading files need.
Source: src/loader/MultiFile.js#L141
Since: 3.7.0
failed
failed: number
Description:
The number of files that failed to load.
Source: src/loader/MultiFile.js#L131
Since: 3.7.0
files
files: Array.<Phaser.Loader.File>
Description:
Array of files that make up this MultiFile.
Source: src/loader/MultiFile.js#L91
Since: 3.7.0
key
key: string
Description:
Unique cache key (unique within its file type).
Source: src/loader/MultiFile.js#L65
Since: 3.7.0
loader
loader: Phaser.Loader.LoaderPlugin
Description:
A reference to the Loader that is going to load this file.
Source: src/loader/MultiFile.js#L47
Since: 3.7.0
path
path: string
Description:
A reference to the Loaders path at the time this MultiFile was created. Used to populate child-files.
Source: src/loader/MultiFile.js#L160
Since: 3.20.0
pending
pending: number
Description:
The number of child files still pending completion. Starts at the total number of child files and is decremented each time a child file finishes loading. When it reaches zero, all children have finished and the MultiFile may be processed.
Source: src/loader/MultiFile.js#L119
Since: 3.7.0
prefix
prefix: string
Description:
A reference to the Loaders prefix at the time this MultiFile was created. Used to populate child-files.
Source: src/loader/MultiFile.js#L170
Since: 3.20.0
state
state: number
Description:
The current state of the file. One of the FILE_CONST values.
Source: src/loader/MultiFile.js#L100
Since: 3.60.0
type
type: string
Description:
The file type string for sorting within the Loader.
Source: src/loader/MultiFile.js#L56
Since: 3.7.0
Public Methods
addToMultiFile
<instance> addToMultiFile(file)
Description:
Adds another child to this MultiFile, increases the pending count and resets the completion status.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| file | Phaser.Loader.File | No | The File to add to this MultiFile. |
Returns: Phaser.Loader.MultiFile - This MultiFile instance.
Source: src/loader/MultiFile.js#L200
Since: 3.7.0
destroy
<instance> destroy()
Description:
Destroy this Multi File and any references it holds.
Source: src/loader/MultiFile.js#L296
Since: 3.60.0
isReadyToProcess
<instance> isReadyToProcess()
Description:
Checks if this MultiFile is ready to process its children or not.
Returns: boolean - true if all children of this MultiFile have loaded, otherwise false.
Source: src/loader/MultiFile.js#L187
Since: 3.7.0
onFileComplete
<instance> onFileComplete(file)
Description:
Called by each File when it finishes loading.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| file | Phaser.Loader.File | No | The File that has completed processing. |
Source: src/loader/MultiFile.js#L223
Since: 3.7.0
onFileFailed
<instance> onFileFailed(file)
Description:
Called by each File that fails to load.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| file | Phaser.Loader.File | No | The File that has failed to load. |
Source: src/loader/MultiFile.js#L241
Since: 3.7.0
pendingDestroy
<instance> pendingDestroy()
Description:
Called once all children of this MultiFile have been added to their caches and the MultiFile is now ready for deletion from the Loader.
It will emit a filecomplete event from the LoaderPlugin.
Fires: Phaser.Loader.Events#event:FILE_COMPLETE, Phaser.Loader.Events#event:FILE_KEY_COMPLETE
Source: src/loader/MultiFile.js#L262
Since: 3.60.0