@awayjs/scene 0.13.269 → 0.13.271

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- console.debug('AwayJS - Scene - 0.13.269');
1
+ console.debug('AwayJS - Scene - 0.13.271');
2
2
  export { Timeline } from './lib/base/Timeline';
3
3
  export { ControllerBase } from './lib/controllers/ControllerBase';
4
4
  export { FirstPersonController } from './lib/controllers/FirstPersonController';
@@ -19,8 +19,8 @@ export declare class MovieClip extends Sprite {
19
19
  static avm1LoadedActions: any[];
20
20
  static movieClipSoundsManagerClass: any;
21
21
  private static _movieClips;
22
- private static _activeSoundsOwners;
23
- static stopAllSounds(): void;
22
+ private static _activeSounds;
23
+ static stopSounds(sound?: WaveAudio): void;
24
24
  static assetType: string;
25
25
  static getNewMovieClip(timeline: Timeline): MovieClip;
26
26
  static clearPool(): void;
@@ -44,7 +44,6 @@ export declare class MovieClip extends Sprite {
44
44
  private _isInit;
45
45
  _sessionID_childs: NumberMap<DisplayObject>;
46
46
  private _sounds;
47
- private _activeSounds;
48
47
  _useHandCursor: boolean;
49
48
  private _soundVolume;
50
49
  private _skipFramesForStream;
@@ -147,7 +146,9 @@ export declare class MovieClip extends Sprite {
147
146
  logHierarchy(depth?: number): void;
148
147
  printHierarchyName(depth: number, target: DisplayObject): void;
149
148
  clear(): void;
150
- private onSoundCompleteInternal;
149
+ private _onChannelCompleteStopError;
150
+ private _stopChannels;
151
+ private _removeSound;
151
152
  }
152
153
  export {};
153
154
  //# sourceMappingURL=MovieClip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MovieClip.d.ts","sourceRoot":"","sources":["../../../lib/display/MovieClip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,SAAS,EAAoB,MAAM,cAAc,CAAC;AAGrF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,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 +25,6 @@ var MovieClip = /** @class */ (function (_super) {
25
25
  _this._isInit = true;
26
26
  _this._sessionID_childs = {};
27
27
  _this._sounds = {};
28
- _this._activeSounds = {};
29
28
  _this._skipFramesForStream = 0;
30
29
  /**
31
30
  * Mark that operation provided by timeline except a script, some operation not allowed from script
@@ -79,12 +78,18 @@ var MovieClip = /** @class */ (function (_super) {
79
78
  if (spriteMode) {
80
79
  _this.transformToSprite();
81
80
  }
82
- _this.onSoundCompleteInternal = _this.onSoundCompleteInternal.bind(_this);
81
+ _this._onChannelCompleteStopError = _this._onChannelCompleteStopError.bind(_this);
83
82
  return _this;
84
83
  }
85
- MovieClip.stopAllSounds = function () {
86
- MovieClip._activeSoundsOwners.forEach(function (e) { return e && e.stopSounds(); });
87
- MovieClip._activeSoundsOwners.clear();
84
+ MovieClip.stopSounds = function (sound) {
85
+ if (sound) {
86
+ if (MovieClip._activeSounds[sound.id])
87
+ MovieClip._activeSounds[sound.id].stop();
88
+ }
89
+ else {
90
+ for (var key in MovieClip._activeSounds)
91
+ MovieClip._activeSounds[key].stop();
92
+ }
88
93
  };
89
94
  MovieClip.getNewMovieClip = function (timeline) {
90
95
  if (MovieClip._movieClips.length) {
@@ -162,26 +167,26 @@ var MovieClip = /** @class */ (function (_super) {
162
167
  if (onSoundComplete)
163
168
  channel.addEventListener(BaseAudioChannel.COMPLETE, onSoundComplete);
164
169
  //internal listener to clear
165
- channel.addEventListener(BaseAudioChannel.COMPLETE, this.onSoundCompleteInternal);
166
- this._sounds[sound.id] = sound;
167
- if (!this._activeSounds[sound.id]) {
168
- this._activeSounds[sound.id] = [];
169
- }
170
+ channel.addEventListener(BaseAudioChannel.COMPLETE, this._onChannelCompleteStopError);
171
+ channel.addEventListener(BaseAudioChannel.STOP, this._onChannelCompleteStopError);
172
+ channel.addEventListener(BaseAudioChannel.ERROR, this._onChannelCompleteStopError);
173
+ var id = sound.id;
174
+ if (!this._sounds[id])
175
+ this._sounds[id] = [];
170
176
  // store channels, stop it instead of sounds
171
- this._activeSounds[sound.id].push(channel);
172
- MovieClip._activeSoundsOwners.add(this);
177
+ this._sounds[id].push(channel);
178
+ //store active sound
179
+ MovieClip._activeSounds[id] = sound;
173
180
  };
174
181
  MovieClip.prototype.stopSounds = function (sound) {
175
182
  if (sound === void 0) { sound = null; }
176
183
  if (sound) {
177
- this.stopSound(sound);
184
+ if (this._sounds[sound.id])
185
+ this._stopChannels(sound);
178
186
  }
179
187
  else {
180
188
  for (var key in this._sounds)
181
- this.stopSound(this._sounds[key]);
182
- }
183
- if (Object.getOwnPropertyNames(this._sounds).length === 0) {
184
- MovieClip._activeSoundsOwners.delete(this);
189
+ this._stopChannels(sound);
185
190
  }
186
191
  var len = this._children.length;
187
192
  var child;
@@ -278,8 +283,8 @@ var MovieClip = /** @class */ (function (_super) {
278
283
  return;
279
284
  this._soundVolume = value;
280
285
  var channels;
281
- for (var key in this._activeSounds)
282
- if ((channels = this._activeSounds[key]))
286
+ for (var key in this._sounds)
287
+ if ((channels = this._sounds[key]))
283
288
  for (var _i = 0, channels_1 = channels; _i < channels_1.length; _i++) {
284
289
  var c = channels_1[_i];
285
290
  c.volume = value;
@@ -289,21 +294,7 @@ var MovieClip = /** @class */ (function (_super) {
289
294
  configurable: true
290
295
  });
291
296
  MovieClip.prototype.stopSound = function (sound) {
292
- if (this._sounds[sound.id]) {
293
- this._sounds[sound.id].stop();
294
- delete this._sounds[sound.id];
295
- if (Object.getOwnPropertyNames(this._sounds).length === 0) {
296
- MovieClip._activeSoundsOwners.delete(this);
297
- }
298
- var channels = this._activeSounds[sound.id];
299
- if (channels) {
300
- for (var _i = 0, channels_2 = channels; _i < channels_2.length; _i++) {
301
- var c = channels_2[_i];
302
- c.stop();
303
- }
304
- delete this._activeSounds[sound.id];
305
- }
306
- }
297
+ MovieClip.stopSounds(sound);
307
298
  };
308
299
  MovieClip.prototype.buttonReset = function () {
309
300
  if (this._isButton && !this.buttonEnabled) {
@@ -708,18 +699,31 @@ var MovieClip = /** @class */ (function (_super) {
708
699
  */
709
700
  _super.prototype.clear.call(this);
710
701
  };
711
- MovieClip.prototype.onSoundCompleteInternal = function (event) {
702
+ MovieClip.prototype._onChannelCompleteStopError = function (event) {
712
703
  var channel = event.target;
713
704
  var sound = channel.owner;
714
- var channels = this._activeSounds[sound.id];
715
- var index = channels.indexOf(channel);
705
+ var channels = this._sounds[sound.id];
706
+ var index = channels ? channels.indexOf(channel) : -1;
716
707
  if (index != -1) {
717
708
  channels.splice(index, 1);
709
+ if (channels.length === 0)
710
+ this._removeSound(sound);
718
711
  }
719
- if (channels.length === 0)
720
- delete this._sounds[sound.id];
721
- if (Object.getOwnPropertyNames(this._sounds).length === 0)
722
- MovieClip._activeSoundsOwners.delete(this);
712
+ };
713
+ MovieClip.prototype._stopChannels = function (sound) {
714
+ var id = sound.id;
715
+ var channels = this._sounds[id];
716
+ for (var _i = 0, channels_2 = channels; _i < channels_2.length; _i++) {
717
+ var c = channels_2[_i];
718
+ c.stop();
719
+ }
720
+ };
721
+ MovieClip.prototype._removeSound = function (sound) {
722
+ //remove sound from local sounds
723
+ delete this._sounds[sound.id];
724
+ //remove sound from active sounds
725
+ if (!sound.isPlaying)
726
+ delete MovieClip._activeSounds[sound.id];
723
727
  };
724
728
  //todo: this 3 are no longer used (?)
725
729
  MovieClip.avm1ScriptQueue = [];
@@ -727,7 +731,7 @@ var MovieClip = /** @class */ (function (_super) {
727
731
  MovieClip.avm1LoadedActions = [];
728
732
  MovieClip.movieClipSoundsManagerClass = null;
729
733
  MovieClip._movieClips = new Array();
730
- MovieClip._activeSoundsOwners = new Set();
734
+ MovieClip._activeSounds = {};
731
735
  MovieClip.assetType = '[asset MovieClip]';
732
736
  return MovieClip;
733
737
  }(Sprite));
package/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- console.debug('AwayJS - Scene - 0.13.269');
1
+ console.debug('AwayJS - Scene - 0.13.271');
2
2
 
3
3
  export { IDisplayObjectAdapter } from './lib/adapters/IDisplayObjectAdapter';
4
4
  export { IMovieClipAdapter } from './lib/adapters/IMovieClipAdapter';
@@ -30,11 +30,16 @@ export class MovieClip extends Sprite {
30
30
  public static movieClipSoundsManagerClass = null;
31
31
 
32
32
  private static _movieClips: Array<MovieClip> = new Array<MovieClip>();
33
- private static _activeSoundsOwners: Set<MovieClip> = new Set<MovieClip>();
33
+ private static _activeSounds: Record<number, WaveAudio> = {};
34
34
 
35
- public static stopAllSounds() {
36
- MovieClip._activeSoundsOwners.forEach(e => e && e.stopSounds());
37
- MovieClip._activeSoundsOwners.clear();
35
+ public static stopSounds(sound?: WaveAudio) {
36
+ if (sound) {
37
+ if (MovieClip._activeSounds[sound.id])
38
+ MovieClip._activeSounds[sound.id].stop();
39
+ } else {
40
+ for (const key in MovieClip._activeSounds)
41
+ MovieClip._activeSounds[key].stop();
42
+ }
38
43
  }
39
44
 
40
45
  public static assetType: string = '[asset MovieClip]';
@@ -86,8 +91,7 @@ export class MovieClip extends Sprite {
86
91
 
87
92
  public _sessionID_childs: NumberMap<DisplayObject> = {};
88
93
 
89
- private _sounds: Record<number, WaveAudio> = {};
90
- private _activeSounds: Record<number, IAudioChannel[]> = {};
94
+ private _sounds: Record<number, IAudioChannel[]> = {};
91
95
 
92
96
  public _useHandCursor: boolean;
93
97
 
@@ -195,7 +199,7 @@ export class MovieClip extends Sprite {
195
199
  this.transformToSprite();
196
200
  }
197
201
 
198
- this.onSoundCompleteInternal = this.onSoundCompleteInternal.bind(this);
202
+ this._onChannelCompleteStopError = this._onChannelCompleteStopError.bind(this);
199
203
  }
200
204
 
201
205
  /**
@@ -238,29 +242,30 @@ export class MovieClip extends Sprite {
238
242
  channel.addEventListener(BaseAudioChannel.COMPLETE, onSoundComplete);
239
243
 
240
244
  //internal listener to clear
241
- channel.addEventListener(BaseAudioChannel.COMPLETE, this.onSoundCompleteInternal);
245
+ channel.addEventListener(BaseAudioChannel.COMPLETE, this._onChannelCompleteStopError);
246
+ channel.addEventListener(BaseAudioChannel.STOP, this._onChannelCompleteStopError);
247
+ channel.addEventListener(BaseAudioChannel.ERROR, this._onChannelCompleteStopError);
242
248
 
243
- this._sounds[sound.id] = sound;
249
+ const id = sound.id;
244
250
 
245
- if (!this._activeSounds[sound.id]) {
246
- this._activeSounds[sound.id] = [];
247
- }
251
+ if (!this._sounds[id])
252
+ this._sounds[id] = [];
248
253
 
249
254
  // store channels, stop it instead of sounds
250
- this._activeSounds[sound.id].push(channel);
251
- MovieClip._activeSoundsOwners.add(this);
255
+ this._sounds[id].push(channel);
256
+
257
+ //store active sound
258
+ MovieClip._activeSounds[id] = sound;
252
259
  }
253
260
 
254
261
  public stopSounds(sound: WaveAudio = null) {
262
+
255
263
  if (sound) {
256
- this.stopSound(sound);
264
+ if (this._sounds[sound.id])
265
+ this._stopChannels(sound);
257
266
  } else {
258
267
  for (const key in this._sounds)
259
- this.stopSound(this._sounds[key]);
260
- }
261
-
262
- if (Object.getOwnPropertyNames(this._sounds).length === 0) {
263
- MovieClip._activeSoundsOwners.delete(this);
268
+ this._stopChannels(sound);
264
269
  }
265
270
 
266
271
  const len: number = this._children.length;
@@ -364,27 +369,13 @@ export class MovieClip extends Sprite {
364
369
  this._soundVolume = value;
365
370
 
366
371
  let channels: IAudioChannel[];
367
- for (const key in this._activeSounds)
368
- if ((channels = this._activeSounds[key]))
372
+ for (const key in this._sounds)
373
+ if ((channels = this._sounds[key]))
369
374
  for (const c of channels) c.volume = value;
370
375
  }
371
376
 
372
377
  public stopSound(sound: WaveAudio) {
373
- if (this._sounds[sound.id]) {
374
- this._sounds[sound.id].stop();
375
- delete this._sounds[sound.id];
376
-
377
- if (Object.getOwnPropertyNames(this._sounds).length === 0) {
378
- MovieClip._activeSoundsOwners.delete(this);
379
- }
380
-
381
- const channels = this._activeSounds[sound.id];
382
- if (channels) {
383
- for (const c of channels) c.stop();
384
-
385
- delete this._activeSounds[sound.id];
386
- }
387
- }
378
+ MovieClip.stopSounds(sound);
388
379
  }
389
380
 
390
381
  public buttonReset() {
@@ -858,21 +849,35 @@ export class MovieClip extends Sprite {
858
849
  super.clear();
859
850
  }
860
851
 
861
- private onSoundCompleteInternal(event: EventBase): void {
852
+ private _onChannelCompleteStopError(event: EventBase): void {
862
853
  const channel: IAudioChannel = event.target;
863
854
  const sound = channel.owner;
864
- const channels = this._activeSounds[sound.id];
865
- const index = channels.indexOf(channel);
855
+ const channels = this._sounds[sound.id];
856
+ const index = channels ? channels.indexOf(channel) : -1;
866
857
 
867
858
  if (index != -1) {
868
859
  channels.splice(index, 1);
860
+
861
+ if (channels.length === 0)
862
+ this._removeSound(sound);
869
863
  }
864
+ }
865
+
866
+ private _stopChannels(sound: WaveAudio) {
867
+ const id: number = sound.id;
868
+ const channels = this._sounds[id];
869
+
870
+ for (const c of channels)
871
+ c.stop();
872
+ }
870
873
 
871
- if (channels.length === 0)
872
- delete this._sounds[sound.id];
874
+ private _removeSound(sound: WaveAudio): void {
875
+ //remove sound from local sounds
876
+ delete this._sounds[sound.id];
873
877
 
874
- if (Object.getOwnPropertyNames(this._sounds).length === 0)
875
- MovieClip._activeSoundsOwners.delete(this);
878
+ //remove sound from active sounds
879
+ if (!sound.isPlaying)
880
+ delete MovieClip._activeSounds[sound.id];
876
881
  }
877
882
  }
878
883
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awayjs/scene",
3
- "version": "0.13.269",
3
+ "version": "0.13.271",
4
4
  "description": "AwayJS scene classes",
5
5
  "main": "bundle/awayjs-scene.umd.js",
6
6
  "module": "dist/index.js",