Skip to main content
Version: Phaser v4.0.0-rc.6

Phaser.Loader.File

createObjectURL

<static> createObjectURL(image, blob, defaultType)

Description:

Static method for creating object URL using URL API and setting it as image 'src' attribute.

If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader.

Parameters:

nametypeoptionaldescription
imageHTMLImageElementNoImage object which 'src' attribute should be set to object URL.
blobBlobNoA Blob object to create an object URL for.
defaultTypestringNoDefault mime type used if blob type is not available.

Source: src/loader/File.js#L564
Since: 3.7.0

revokeObjectURL

<static> revokeObjectURL(image)

Description:

Static method for releasing an existing object URL which was previously created

by calling Phaser.Loader.File.createObjectURL method.

Parameters:

nametypeoptionaldescription
imageHTMLImageElementNoImage object which 'src' attribute should be revoked.

Source: src/loader/File.js#L598
Since: 3.7.0

Phaser.Loader.FileTypesManager

install

<static> install(loader)

Description:

Static method called when a LoaderPlugin is created.

Loops through the local types object and injects all of them as

properties into the LoaderPlugin instance.

Parameters:

nametypeoptionaldescription
loaderPhaser.Loader.LoaderPluginNoThe LoaderPlugin to install the types into.

Source: src/loader/FileTypesManager.js#L15
Since: 3.0.0

register

<static> register(key, factoryFunction)

Description:

Static method called directly by the File Types.

The key is a reference to the function used to load the files via the Loader, i.e. image.

Parameters:

nametypeoptionaldescription
keystringNoThe key that will be used as the method name in the LoaderPlugin.
factoryFunctionfunctionNoThe function that will be called when LoaderPlugin.key is invoked.

Source: src/loader/FileTypesManager.js#L34
Since: 3.0.0

destroy

<static> destroy()

Description:

Removed all associated file types.

Source: src/loader/FileTypesManager.js#L50
Since: 3.0.0

GetURL

<static> GetURL(file, baseURL)

Description:

Given a File and a baseURL value this returns the URL the File will use to download from.

Parameters:

nametypeoptionaldescription
filePhaser.Loader.FileNoThe File object.
baseURLstringNoA default base URL.

Returns: string - The URL the File will use.

Source: src/loader/GetURL.js#L7
Since: 3.0.0

MergeXHRSettings

<static> MergeXHRSettings(global, local)

Description:

Takes two XHRSettings Objects and creates a new XHRSettings object from them.

The new object is seeded by the values given in the global settings, but any setting in

the local object overrides the global ones.

Parameters:

nametypeoptionaldescription
globalPhaser.Types.Loader.XHRSettingsObjectNoThe global XHRSettings object.
localPhaser.Types.Loader.XHRSettingsObjectNoThe local XHRSettings object.

Returns: Phaser.Types.Loader.XHRSettingsObject - A newly formed XHRSettings object.

Source: src/loader/MergeXHRSettings.js#L10
Since: 3.0.0

XHRLoader

<static> XHRLoader(file, globalXHRSettings)

Description:

Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings

and starts the download of it. It uses the Files own XHRSettings and merges them

with the global XHRSettings object to set the xhr values before download.

Parameters:

nametypeoptionaldescription
filePhaser.Loader.FileNoThe File to download.
globalXHRSettingsPhaser.Types.Loader.XHRSettingsObjectNoThe global XHRSettings object.

Returns: XMLHttpRequest - The XHR object, or a FakeXHR Object in the base of base64 data.

Source: src/loader/XHRLoader.js#L9
Since: 3.0.0

XHRSettings

<static> XHRSettings([responseType], [async], [user], [password], [timeout], [withCredentials])

Description:

Creates an XHRSettings Object with default values.

Parameters:

nametypeoptionaldefaultdescription
responseTypeXMLHttpRequestResponseTypeYes"''"The responseType, such as 'text'.
asyncbooleanYestrueShould the XHR request use async or not?
userstringYes"''"Optional username for the XHR request.
passwordstringYes"''"Optional password for the XHR request.
timeoutnumberYes0Optional XHR timeout value.
withCredentialsbooleanYesfalseOptional XHR withCredentials value.

Returns: Phaser.Types.Loader.XHRSettingsObject - The XHRSettings object as used by the Loader.

Source: src/loader/XHRSettings.js#L7
Since: 3.0.0