@@ -12,12 +12,6 @@ var MergeXHRSettings = require('./MergeXHRSettings');
1212var XHRLoader = require ( './XHRLoader' ) ;
1313var XHRSettings = require ( './XHRSettings' ) ;
1414
15- /**
16- * @callback FileProcessCallback
17- *
18- * @param {Phaser.Loader.File } file - [description]
19- */
20-
2115/**
2216 * @typedef {object } FileConfig
2317 *
@@ -33,15 +27,16 @@ var XHRSettings = require('./XHRSettings');
3327
3428/**
3529 * @classdesc
36- * [description]
30+ * The base File class used by all File Types that the Loader can support.
31+ * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods.
3732 *
3833 * @class File
3934 * @memberOf Phaser.Loader
4035 * @constructor
4136 * @since 3.0.0
4237 *
4338 * @param {Phaser.Loader.LoaderPlugin } loader - The Loader that is going to load this File.
44- * @param {FileConfig } fileConfig - [description]
39+ * @param {FileConfig } fileConfig - The file configuration object, as created by the file type.
4540 */
4641var File = new Class ( {
4742
@@ -99,6 +94,7 @@ var File = new Class({
9994
10095 /**
10196 * The URL of the file, not including baseURL.
97+ * Automatically has Loader.path prepended to it.
10298 *
10399 * @name Phaser.Loader.File#url
104100 * @type {string }
@@ -116,7 +112,8 @@ var File = new Class({
116112 }
117113
118114 /**
119- * Set when the Loader calls 'load' on this file.
115+ * The final URL this file will load from, including baseURL and path.
116+ * Set automatically when the Loader calls 'load' on this file.
120117 *
121118 * @name Phaser.Loader.File#src
122119 * @type {string }
@@ -200,7 +197,7 @@ var File = new Class({
200197 this . crossOrigin = undefined ;
201198
202199 /**
203- * The processed file data, stored in here after the file has loaded.
200+ * The processed file data, stored here after the file has loaded.
204201 *
205202 * @name Phaser.Loader.File#data
206203 * @type {* }
@@ -212,14 +209,14 @@ var File = new Class({
212209 * A config object that can be used by file types to store transitional data.
213210 *
214211 * @name Phaser.Loader.File#config
215- * @type {object }
212+ * @type {* }
216213 * @since 3.0.0
217214 */
218215 this . config = GetFastValue ( fileConfig , 'config' , { } ) ;
219216
220217 /**
221218 * If this is a multipart file, i.e. an atlas and its json together, then this is a reference
222- * to the linked file . Set and used internally by the Loader.
219+ * to the parent MultiFile . Set and used internally by the Loader or specific file types .
223220 *
224221 * @name Phaser.Loader.File#multiFile
225222 * @type {?Phaser.Loader.MultiFile }
@@ -239,6 +236,14 @@ var File = new Class({
239236 this . linkFile ;
240237 } ,
241238
239+ /**
240+ * Links this File with another, so they depend upon each other for loading and processing.
241+ *
242+ * @method Phaser.Loader.File#setLink
243+ * @since 3.7.0
244+ *
245+ * @param {Phaser.Loader.File } fileB - The file to link to this one.
246+ */
242247 setLink : function ( fileB )
243248 {
244249 this . linkFile = fileB ;
@@ -247,7 +252,7 @@ var File = new Class({
247252 } ,
248253
249254 /**
250- * Resets the XHRLoader instance.
255+ * Resets the XHRLoader instance this file is using .
251256 *
252257 * @method Phaser.Loader.File#resetXHR
253258 * @since 3.0.0
@@ -264,7 +269,8 @@ var File = new Class({
264269
265270 /**
266271 * Called by the Loader, starts the actual file downloading.
267- * During the load the methods onLoad, onProgress, etc are called based on the XHR events.
272+ * During the load the methods onLoad, onError and onProgress are called, based on the XHR events.
273+ * You shouldn't normally call this method directly, it's meant to be invoked by the Loader.
268274 *
269275 * @method Phaser.Loader.File#load
270276 * @since 3.0.0
@@ -289,9 +295,9 @@ var File = new Class({
289295 // The creation of this XHRLoader starts the load process going.
290296 // It will automatically call the following, based on the load outcome:
291297 //
292- // xhr.onload = file .onLoad.bind(file);
293- // xhr.onerror = file .onError.bind(file);
294- // xhr.onprogress = file .onProgress.bind(file);
298+ // xhr.onload = this .onLoad
299+ // xhr.onerror = this .onError
300+ // xhr.onprogress = this .onProgress
295301
296302 this . xhrLoader = XHRLoader ( this , this . loader . xhr ) ;
297303 }
@@ -352,7 +358,8 @@ var File = new Class({
352358 } ,
353359
354360 /**
355- * Usually overridden by the FileTypes and is called by Loader.finishedLoading.
361+ * Usually overridden by the FileTypes and is called by Loader.nextFile.
362+ * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage.
356363 *
357364 * @method Phaser.Loader.File#onProcess
358365 * @since 3.0.0
@@ -365,7 +372,7 @@ var File = new Class({
365372 } ,
366373
367374 /**
368- * Called when the File has completed loading .
375+ * Called when the File has completed processing .
369376 * Checks on the state of its multifile, if set.
370377 *
371378 * @method Phaser.Loader.File#onProcessComplete
@@ -384,7 +391,7 @@ var File = new Class({
384391 } ,
385392
386393 /**
387- * Called when the File has completed loading .
394+ * Called when the File has completed processing but it generated an error .
388395 * Checks on the state of its multifile, if set.
389396 *
390397 * @method Phaser.Loader.File#onProcessError
@@ -419,7 +426,6 @@ var File = new Class({
419426
420427 /**
421428 * Adds this file to its target cache upon successful loading and processing.
422- * It will emit a `filecomplete` event from the LoaderPlugin.
423429 * This method is often overridden by specific file types.
424430 *
425431 * @method Phaser.Loader.File#addToCache
@@ -435,12 +441,20 @@ var File = new Class({
435441 this . pendingDestroy ( ) ;
436442 } ,
437443
444+ /**
445+ * @event Phaser.Loader.File#fileCompleteEvent
446+ * @param {string } key - The key of the file that just loaded and finished processing.
447+ * @param {string } type - The type of the file that just loaded and finished processing.
448+ * @param {any } data - The data of the file.
449+ */
450+
438451 /**
439452 * Adds this file to its target cache upon successful loading and processing.
440453 * It will emit a `filecomplete` event from the LoaderPlugin.
441454 * This method is often overridden by specific file types.
442455 *
443456 * @method Phaser.Loader.File#pendingDestroy
457+ * @fires Phaser.Loader.File#fileCompleteEvent
444458 * @since 3.7.0
445459 */
446460 pendingDestroy : function ( data )
0 commit comments