1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444 | 2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
37x
37x
37x
37x
37x
37x
37x
37x
37x
37x
37x
37x
37x
37x
37x
37x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
| var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
(function (factory) {
Eif (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); Iif (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports", '../BaseObject'], factory);
}
})(function (require, exports) {
"use strict";
var BaseObject_1 = require('../BaseObject');
/**
* The {{#crossLink "BaseEvent"}}{{/crossLink}} class is used as the base class for the creation of Event objects, which are passed as parameters to event listeners when an event occurs.
*
* The properties of the {{#crossLink "BaseEvent"}}{{/crossLink}} class carry basic information about an event, such as the event's type or whether the event's default behavior can be canceled.
*
* For many events, such as the events represented by the Event class constants, this basic information is sufficient. Other events, however, may require more
* detailed information.
* @class BaseEvent
* @extends BaseObject
* @param type {string} The type of event. The type is case-sensitive.
* @param [bubbles=false] {boolean} Indicates whether an event is a bubbling event. If the event can bubble, this value is true; otherwise it is false.
* Note: With event-bubbling you can let one Event subsequently call on every ancestor ({{#crossLink "EventDispatcher/parent:property"}}{{/crossLink}})
* (containers of containers of etc.) of the {{#crossLink "DisplayObjectContainer"}}{{/crossLink}} that originally dispatched the Event, all the way up to the surface ({{#crossLink "Stage"}}{{/crossLink}}). Any classes that do not have a parent cannot bubble.
* @param [cancelable=false] {boolean} Indicates whether the behavior associated with the event can be prevented. If the behavior can be canceled, this value is true; otherwise it is false.
* @param [data=null] {any} Use to pass any type of data with the event.
* @module StructureJS
* @submodule event
* @requires Extend
* @requires BaseObject
* @constructor
* @author Robert S. (www.codeBelt.com)
* @example
* // Example: how to create a custom event by extending BaseEvent.
*
* class CountryEvent extends BaseEvent {
*
* CHANGE_COUNTRY = 'CountryEvent.changeCountry';
*
* constructor(type, bubbles = false, cancelable = false, data = null) {
* super(type, bubbles, cancelable, data);
*
* this.countryName = null;
* }
* }
*
* // Example: how to use the custom event.
* let event = new CountryEvent(CountryEvent.CHANGE_COUNTRY);
* event.countryName = 'Canada';
* this.dispatchEvent(event);
*/
var BaseEvent = (function (_super) {
__extends(BaseEvent, _super);
function BaseEvent(type, bubbles, cancelable, data) {
Eif (bubbles === void 0) { bubbles = false; }
Eif (cancelable === void 0) { cancelable = false; }
Eif (data === void 0) { data = null; }
_super.call(this);
/**
* The type of event.
*
* @property type
* @type {string}
* @default null
* @public
* @readOnly
*/
this.type = null;
/**
* A reference to the object that originally dispatched the event.
*
* @property target
* @type {any}
* @default null
* @public
* @readOnly
*/
this.target = null;
/**
* The currentTarget property always points to the {{#crossLink "DisplayObjectContainer"}}{{/crossLink}} that the event is currently processing (i.e. bubbling at).
*
* @property currentTarget
* @type {any}
* @default null
* @public
* @readOnly
*/
this.currentTarget = null;
/**
* Used to pass any type of data with the event.
*
* @property data
* @type {any}
* @public
* @default null
*/
this.data = null;
/**
* Indicates whether an event is a bubbling event.
*
* @property bubbles
* @type {boolean}
* @public
* @default false
*/
this.bubbles = false;
/**
* Indicates whether the behavior associated with the event can be prevented.
*
* @property cancelable
* @type {boolean}
* @public
* @default false
*/
this.cancelable = false;
/**
* Indicates if the {{#crossLink "BaseEvent/stopPropagation:method"}}{{/crossLink}} was called on the event object.
*
* @property isPropagationStopped
* @type {boolean}
* @default false
* @public
* @readOnly
*/
this.isPropagationStopped = false;
/**
* Indicates if the {{#crossLink "BaseEvent/stopImmediatePropagation:method"}}{{/crossLink}} was called on the event object.
*
* @property isImmediatePropagationStopped
* @type {boolean}
* @default false
* @public
* @readOnly
*/
this.isImmediatePropagationStopped = false;
this.type = type;
this.bubbles = bubbles;
this.cancelable = cancelable;
this.data = data;
}
/**
* Prevents processing of any event listeners in nodes subsequent to the current node in the event flow.
* This method does not affect any event listeners in the current node (currentTarget). In contrast,
* the {{#crossLink "BaseEvent/stopImmediatePropagation:method"}}{{/crossLink}} method prevents processing
* of event listeners in both the current node and subsequent nodes. Additional calls to this method have no effect.
*
* @method stopPropagation
* @public
* @example
* event.stopPropagation();
*/
BaseEvent.prototype.stopPropagation = function () {
this.isPropagationStopped = true;
};
/**
* Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow.
* This method takes effect immediately, and it affects event listeners in the current node. In contrast,
* the {{#crossLink "BaseEvent/stopPropagation:method"}}{{/crossLink}} method doesn't take effect until
* all the event listeners in the current node finish processing.
*
* @method stopImmediatePropagation
* @public
* @example
* event.stopImmediatePropagation();
*/
BaseEvent.prototype.stopImmediatePropagation = function () {
this.stopPropagation();
this.isImmediatePropagationStopped = true;
};
/**
* Duplicates an instance of an BaseEvent subclass.
*
* Returns a new BaseEvent object that is a copy of the original instance of the BaseEvent object.
*
* The new BaseEvent object includes all the properties of the original.
*
* @method clone
* @returns {BaseEvent}
* @public
* @example
* let cloneOfEvent = event.clone();
*/
BaseEvent.prototype.clone = function () {
var clonedBaseModel = new this.constructor(this.type, this.bubbles, this.cancelable, this.data);
for (var key in this) {
if (this.hasOwnProperty(key)) {
clonedBaseModel[key] = this[key];
}
}
return clonedBaseModel;
};
/**
* The BaseEvent.ACTIVATE constant defines the value of the type property of an activate event object.
*
* @event ACTIVATE
* @type {string}
* @public
* @static
*/
BaseEvent.ACTIVATE = 'BaseEvent.activate';
/**
* The BaseEvent.ADDED constant defines the value of the type property of an added event object.
*
* @event ADDED
* @type {string}
* @public
* @static
*/
BaseEvent.ADDED = 'BaseEvent.added';
/**
* The BaseEvent.ADDED_TO_STAGE constant defines the value of the type property of an addedToStage event object.
*
* @event ADDED_TO_STAGE
* @type {string}
* @public
* @static
*/
BaseEvent.ADDED_TO_STAGE = 'BaseEvent.addedToStage';
/**
* The BaseEvent.CANCEL constant defines the value of the type property of a cancel event object.
*
* @event CANCEL
* @type {string}
* @public
* @static
*/
BaseEvent.CANCEL = 'BaseEvent.cancel';
/**
* The BaseEvent.CHANGE constant defines the value of the type property of a change event object.
*
* @event CHANGE
* @type {string}
* @public
* @static
*/
BaseEvent.CHANGE = 'BaseEvent.change';
/**
* The BaseEvent.CLEAR constant defines the value of the type property of a clear event object.
*
* @event CLEAR
* @type {string}
* @public
* @static
*/
BaseEvent.CLEAR = 'BaseEvent.clear';
/**
* The BaseEvent.CLOSE constant defines the value of the type property of a close event object.
*
* @event CLOSE
* @type {string}
* @public
* @static
*/
BaseEvent.CLOSE = 'BaseEvent.close';
/**
* The BaseEvent.CLOSING constant defines the value of the type property of a closing event object.
*
* @event CLOSING
* @type {string}
* @public
* @static
*/
BaseEvent.CLOSING = 'BaseEvent.closing';
/**
* The BaseEvent.COMPLETE constant defines the value of the type property of a complete event object.
*
* @event COMPLETE
* @type {string}
* @public
* @static
*/
BaseEvent.COMPLETE = 'BaseEvent.complete';
/**
* The BaseEvent.CONNECT constant defines the value of the type property of a connect event object.
*
* @event CONNECT
* @type {string}
* @public
* @static
*/
BaseEvent.CONNECT = 'BaseEvent.connect';
/**
* Defines the value of the type property of a copy event object.
*
* @event COPY
* @type {string}
* @public
* @static
*/
BaseEvent.COPY = 'BaseEvent.copy';
/**
* Defines the value of the type property of a cut event object.
*
* @event CUT
* @type {string}
* @public
* @static
*/
BaseEvent.CUT = 'BaseEvent.cut';
/**
* The BaseEvent.DEACTIVATE constant defines the value of the type property of a deactivate event object.
*
* @event DEACTIVATE
* @type {string}
* @public
* @static
*/
BaseEvent.DEACTIVATE = 'BaseEvent.deactivate';
/**
* The BaseEvent.DISPLAYING constant defines the value of the type property of a displaying event object.
*
* @event DISPLAYING
* @type {string}
* @public
* @static
*/
BaseEvent.DISPLAYING = 'BaseEvent.displaying';
/**
* The BaseEvent.ENTER_FRAME constant defines the value of the type property of an enterFrame event object.
*
* @event ENTER_FRAME
* @type {string}
* @public
* @static
*/
BaseEvent.ENTER_FRAME = 'BaseEvent.enterFrame';
/**
* The BaseEvent.EXIT_FRAME constant defines the value of the type property of an exitFrame event object.
*
* @event EXIT_FRAME
* @type {string}
* @public
* @static
*/
BaseEvent.EXIT_FRAME = 'BaseEvent.exitFrame';
/**
* The BaseEvent.EXITING constant defines the value of the type property of an exiting event object.
*
* @event EXITING
* @type {string}
* @public
* @static
*/
BaseEvent.EXITING = 'BaseEvent.exiting';
/**
* The BaseEvent.FULL_SCREEN constant defines the value of the type property of a fullScreen event object.
*
* @event FULLSCREEN
* @type {string}
* @public
* @static
*/
BaseEvent.FULLSCREEN = 'BaseEvent.fullScreen';
/**
* The BaseEvent.INIT constant defines the value of the type property of an init event object.
*
* @event INIT
* @type {string}
* @public
* @static
*/
BaseEvent.INIT = 'BaseEvent.init';
/**
* The BaseEvent.NETWORK_CHANGE constant defines the value of the type property of a networkChange event object.
*
* @event NETWORK_CHANGE
* @type {string}
* @public
* @static
*/
BaseEvent.NETWORK_CHANGE = 'BaseEvent.networkChange';
/**
* The BaseEvent.OPEN constant defines the value of the type property of an open event object.
*
* @event OPEN
* @type {string}
* @public
* @static
*/
BaseEvent.OPEN = 'BaseEvent.open';
/**
* The BaseEvent.PASTE constant defines the value of the type property of a paste event object.
*
* @event PASTE
* @type {string}
* @public
* @static
*/
BaseEvent.PASTE = 'BaseEvent.paste';
/**
* The BaseEvent.PREPARING constant defines the value of the type property of a preparing event object.
*
* @event PREPARING
* @type {string}
* @public
* @static
*/
BaseEvent.PREPARING = 'BaseEvent.preparing';
/**
* The BaseEvent.REMOVED constant defines the value of the type property of a removed event object.
*
* @event REMOVED
* @type {string}
* @public
* @static
*/
BaseEvent.REMOVED = 'BaseEvent.removed';
/**
* The BaseEvent.RENDER constant defines the value of the type property of a render event object.
*
* @event RENDER
* @type {string}
* @public
* @static
*/
BaseEvent.RENDER = 'BaseEvent.render';
/**
* The BaseEvent.RESIZE constant defines the value of the type property of a resize event object.
*
* @event RESIZE
* @type {string}
* @public
* @static
*/
BaseEvent.RESIZE = 'BaseEvent.resize';
/**
* The BaseEvent.SELECTED constant defines the value of the type property of a selected event object.
*
* @event SELECTED
* @type {string}
* @public
* @static
*/
BaseEvent.SELECTED = 'BaseEvent.selected';
return BaseEvent;
}(BaseObject_1.default));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = BaseEvent;
});
|