script(key, url, callback, callbackContext) → {Phaser.Loader}
Adds a JavaScript file to the current load queue.
The file is not loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
The key must be a unique String.
The URL can be relative or absolute. If the URL is relative the Loader.baseURL
and Loader.path
values will be prepended to it.
If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
and no URL is given then the Loader will set the URL to be "alien.js". It will always add .js
as the extension.
If you do not desire this action then provide a URL.
Upon successful load the JavaScript is automatically turned into a script tag and executed, so be careful what you load!
A callback, which will be invoked as the script tag has been created, can also be specified.
The callback must return relevant data
.
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
key | string | Unique asset key of the script file. | ||
url | string | <optional> | URL of the JavaScript file. If undefined or | |
callback | function | <optional> | (none) | Optional callback that will be called after the script tag has loaded, so you can perform additional processing. |
callbackContext | object | <optional> | (loader) | The context under which the callback will be applied. If not specified it will use the Phaser Loader as the context. |
Returns
This Loader instance.
- Source code: loader/Loader.js (Line 876)
Please login to continue.