1 /**
  2  * The MIT License (MIT)
  3  *
  4  * Copyright (c) 2016 DeNA Co., Ltd.
  5  *
  6  * Permission is hereby granted, free of charge, to any person obtaining a copy
  7  * of this software and associated documentation files (the "Software"), to deal
  8  * in the Software without restriction, including without limitation the rights
  9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10  * copies of the Software, and to permit persons to whom the Software is
 11  * furnished to do so, subject to the following conditions:
 12  *
 13  * The above copyright notice and this permission notice shall be included in
 14  * all copies or substantial portions of the Software.
 15  *
 16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 22  * SOFTWARE.
 23  */
 24 
 25 /// <reference path="base.js"/>
 26 /// <reference path="event.js"/>
 27 
 28 /**
 29  * The base class for file events dispatched by the createjs.Loader class and
 30  * the createjs.LoadQueue class.
 31  * @param {string} type
 32  * @param {boolean} bubbles
 33  * @param {boolean} cancelable
 34  * @param {Object} item
 35  * @extends {createjs.Event}
 36  * @constructor
 37  */
 38 createjs.FileEvent =
 39     function(type, bubbles, cancelable, item) {
 40   createjs.Event.call(this, type, bubbles, cancelable);
 41 
 42   /**
 43    * The item provided by games. The createjs.LoadQueue class sets the item
 44    * provided by games to this property when it dispatches an event.
 45    * @type {Object}
 46    */
 47   this['item'] = item;
 48 };
 49 createjs.inherits('FileEvent', createjs.FileEvent, createjs.Event);
 50 
 51 /**
 52  * A class that represents a fileerror event.
 53  * @param {string} type
 54  * @param {boolean} bubbles
 55  * @param {boolean} cancelable
 56  * @param {Object} item
 57  * @param {string} message
 58  * @extends {createjs.FileEvent}
 59  * @constructor
 60  */
 61 createjs.FileErrorEvent =
 62     function(type, bubbles, cancelable, item, message) {
 63   createjs.FileEvent.call(this, type, bubbles, cancelable, item);
 64 };
 65 createjs.inherits('FileErrorEvent',
 66                   createjs.FileErrorEvent,
 67                   createjs.FileEvent);
 68 
 69 /**
 70  * A class that represents a fileprogress event.
 71  * @param {string} type
 72  * @param {boolean} bubbles
 73  * @param {boolean} cancelable
 74  * @param {Object} item
 75  * @param {number} loaded
 76  * @param {number} total
 77  * @param {number} progress
 78  * @extends {createjs.FileEvent}
 79  * @constructor
 80  */
 81 createjs.FileProgressEvent =
 82     function(type, bubbles, cancelable, item, loaded, total, progress) {
 83   createjs.FileEvent.call(this, type, bubbles, cancelable, item);
 84 
 85   /**
 86    * The amount that has been loaded so far.
 87    * @type {number}
 88    */
 89   this['loaded'] = loaded;
 90 
 91   /**
 92    * The total number of bytes read by a loader object.
 93    * @type {number}
 94    */
 95   this['total'] = total;
 96 
 97   /**
 98    * The ratio that has been loaded between 0 and 1.
 99    * @type {number}
100    */
101   this['progress'] = progress;
102 };
103 createjs.inherits('FileProgressEvent',
104                   createjs.FileProgressEvent,
105                   createjs.FileEvent);
106 
107 /**
108  * A class that represents a fileload event.
109  * @param {string} type
110  * @param {boolean} bubbles
111  * @param {boolean} cancelable
112  * @param {Object} item
113  * @param {*} result
114  * @param {*} rawResult
115  * @extends {createjs.FileEvent}
116  * @constructor
117  */
118 createjs.FileLoadEvent =
119     function(type, bubbles, cancelable, item, result, rawResult) {
120   createjs.FileEvent.call(this, type, bubbles, cancelable, item);
121 
122   /**
123    * The load result. (The type of this object depends on the file type.)
124    * @type {*}
125    */
126   this['result'] = result;
127 
128   /**
129    * The raw result. (This object should be either an ArrayBuffer object or a
130    * string.)
131    * @type {*}
132    */
133   this['rawResult'] = rawResult;
134 };
135 createjs.inherits('FileLoadEvent',
136                   createjs.FileLoadEvent,
137                   createjs.FileEvent);
138