@awayjs/scene 0.13.252 → 0.13.253
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/bundle/awayjs-scene.umd.js +59 -70
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/bundle/awayjs-scene.umd.min.js.map +1 -1
- package/bundle/awayjs-scene.umd.min.js.map.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/base/Timeline.js +7 -7
- package/dist/lib/display/MovieClip.d.ts +6 -6
- package/dist/lib/display/MovieClip.d.ts.map +1 -1
- package/dist/lib/display/MovieClip.js +48 -58
- package/index.ts +1 -1
- package/lib/base/Timeline.ts +8 -8
- package/lib/display/MovieClip.ts +53 -58
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
console.debug('AwayJS - Scene - 0.13.
|
|
1
|
+
console.debug('AwayJS - Scene - 0.13.253');
|
|
2
2
|
export { Timeline } from './lib/base/Timeline';
|
|
3
3
|
export { ControllerBase } from './lib/controllers/ControllerBase';
|
|
4
4
|
export { FirstPersonController } from './lib/controllers/FirstPersonController';
|
|
@@ -336,16 +336,16 @@ var Timeline = /** @class */ (function () {
|
|
|
336
336
|
for (var i = start_index; i < end_index; i++) {
|
|
337
337
|
var audioProps = this.audioPool[this.add_sounds_stream[i]];
|
|
338
338
|
if (audioProps) {
|
|
339
|
+
var sound = audioProps.sound;
|
|
340
|
+
if (!sound) {
|
|
341
|
+
console.warn('[Timeline] Missing sound in audioProps!', audioProps);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
339
344
|
if (audioProps.cmd == 15) { // start sound
|
|
340
|
-
|
|
341
|
-
if (!child) {
|
|
342
|
-
console.warn('[Timeline] Missed sound to start!', audioProps);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
target_mc.startSound(audioProps.id, child, audioProps.props.loopCount || 0);
|
|
345
|
+
target_mc.startSound(sound, audioProps.props.loopCount || 0);
|
|
346
346
|
}
|
|
347
347
|
else if (audioProps.cmd == 16) { // stop sound
|
|
348
|
-
target_mc.stopSound(
|
|
348
|
+
target_mc.stopSound(sound);
|
|
349
349
|
}
|
|
350
350
|
//console.log("start sound:", child);
|
|
351
351
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WaveAudio } from '@awayjs/core';
|
|
1
|
+
import { WaveAudio, EventBase } from '@awayjs/core';
|
|
2
2
|
import { Timeline } from '../base/Timeline';
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
4
|
import { Sprite } from './Sprite';
|
|
@@ -19,7 +19,6 @@ export declare class MovieClip extends Sprite {
|
|
|
19
19
|
static avm1LoadedActions: any[];
|
|
20
20
|
static movieClipSoundsManagerClass: any;
|
|
21
21
|
private static _movieClips;
|
|
22
|
-
private static _activeSounds;
|
|
23
22
|
private static _activeSoundsOwners;
|
|
24
23
|
static stopAllSounds(): void;
|
|
25
24
|
static assetType: string;
|
|
@@ -45,6 +44,7 @@ export declare class MovieClip extends Sprite {
|
|
|
45
44
|
private _isInit;
|
|
46
45
|
_sessionID_childs: NumberMap<DisplayObject>;
|
|
47
46
|
private _sounds;
|
|
47
|
+
private _activeSounds;
|
|
48
48
|
_useHandCursor: boolean;
|
|
49
49
|
private _parentSoundVolume;
|
|
50
50
|
private _soundVolume;
|
|
@@ -74,8 +74,8 @@ export declare class MovieClip extends Sprite {
|
|
|
74
74
|
* Used for UIComponents, where timeline store more that 1 frame
|
|
75
75
|
*/
|
|
76
76
|
transformToSprite(): void;
|
|
77
|
-
startSound(
|
|
78
|
-
stopSounds(
|
|
77
|
+
startSound(sound: WaveAudio, loopsToPlay: number, onSoundComplete?: (event: EventBase) => void): void;
|
|
78
|
+
stopSounds(sound?: WaveAudio): void;
|
|
79
79
|
/**
|
|
80
80
|
* Compute scene index by global frame index
|
|
81
81
|
* @param frameIndex
|
|
@@ -91,8 +91,7 @@ export declare class MovieClip extends Sprite {
|
|
|
91
91
|
get isPlaying(): boolean;
|
|
92
92
|
get soundVolume(): number;
|
|
93
93
|
set soundVolume(value: number);
|
|
94
|
-
stopSound(
|
|
95
|
-
stopAllSounds(): void;
|
|
94
|
+
stopSound(sound: WaveAudio): void;
|
|
96
95
|
buttonReset(): void;
|
|
97
96
|
getMouseCursor(): string;
|
|
98
97
|
queueFrameScripts(timeline: Timeline, frame_idx: number, scriptPass1: boolean): void;
|
|
@@ -149,6 +148,7 @@ export declare class MovieClip extends Sprite {
|
|
|
149
148
|
logHierarchy(depth?: number): void;
|
|
150
149
|
printHierarchyName(depth: number, target: DisplayObject): void;
|
|
151
150
|
clear(): void;
|
|
151
|
+
private onSoundCompleteInternal;
|
|
152
152
|
}
|
|
153
153
|
export {};
|
|
154
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,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"MovieClip.d.ts","sourceRoot":"","sources":["../../../lib/display/MovieClip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,UAAU,MAAM;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,MAAM;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACb;AACD,qBAAa,SAAU,SAAQ,MAAM;IACpC,OAAc,gBAA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,mBAAmB,EAAE,MAAM,EACpE,mBAAmB,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAClD,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO;IAIxD,uBAAuB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa;IAK9F,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/C,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa;IA0B1D,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;OAEG;IACI,IAAI,IAAI,IAAI;IAKnB;;OAEG;IACI,IAAI,IAAI,IAAI;IAMZ,KAAK,IAAI,SAAS;IAQlB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAelC,oBAAoB,IAAI,IAAI;IAiC5B,YAAY,IAAI,IAAI;IAoB3B,YAAY,CAAC,KAAK,GAAE,MAAU,GAAG,IAAI;IAerC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IASvD,KAAK,IAAI,IAAI;IAqBpB,OAAO,CAAC,uBAAuB;CAgB/B"}
|
|
@@ -3,6 +3,7 @@ import { PartitionBase, EntityNode } from '@awayjs/view';
|
|
|
3
3
|
import { MouseEvent } from '../events/MouseEvent';
|
|
4
4
|
import { FrameScriptManager } from '../managers/FrameScriptManager';
|
|
5
5
|
import { Sprite } from './Sprite';
|
|
6
|
+
import { BaseAudioChannel } from '@awayjs/core/dist/lib/managers/BaseAudioChannel';
|
|
6
7
|
var MovieClip = /** @class */ (function (_super) {
|
|
7
8
|
__extends(MovieClip, _super);
|
|
8
9
|
function MovieClip(timeline, spriteMode) {
|
|
@@ -24,6 +25,7 @@ var MovieClip = /** @class */ (function (_super) {
|
|
|
24
25
|
_this._isInit = true;
|
|
25
26
|
_this._sessionID_childs = {};
|
|
26
27
|
_this._sounds = {};
|
|
28
|
+
_this._activeSounds = {};
|
|
27
29
|
_this._skipFramesForStream = 0;
|
|
28
30
|
/**
|
|
29
31
|
* Mark that operation provided by timeline except a script, some operation not allowed from script
|
|
@@ -78,10 +80,11 @@ var MovieClip = /** @class */ (function (_super) {
|
|
|
78
80
|
if (spriteMode) {
|
|
79
81
|
_this.transformToSprite();
|
|
80
82
|
}
|
|
83
|
+
_this.onSoundCompleteInternal = _this.onSoundCompleteInternal.bind(_this);
|
|
81
84
|
return _this;
|
|
82
85
|
}
|
|
83
86
|
MovieClip.stopAllSounds = function () {
|
|
84
|
-
MovieClip._activeSoundsOwners.forEach(function (e) { return e && e.
|
|
87
|
+
MovieClip._activeSoundsOwners.forEach(function (e) { return e && e.stopSounds(); });
|
|
85
88
|
MovieClip._activeSoundsOwners.clear();
|
|
86
89
|
};
|
|
87
90
|
MovieClip.getNewMovieClip = function (timeline) {
|
|
@@ -154,46 +157,28 @@ var MovieClip = /** @class */ (function (_super) {
|
|
|
154
157
|
timeline.keyframe_firstframes = [timeline.keyframe_firstframes[0]];
|
|
155
158
|
timeline.keyframe_indices = [timeline.keyframe_indices[0]];
|
|
156
159
|
};
|
|
157
|
-
MovieClip.prototype.startSound = function (
|
|
160
|
+
MovieClip.prototype.startSound = function (sound, loopsToPlay, onSoundComplete) {
|
|
158
161
|
var channel = sound.play(0, loopsToPlay);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
if (onSoundComplete)
|
|
163
|
+
channel.addEventListener(BaseAudioChannel.COMPLETE, onSoundComplete);
|
|
164
|
+
//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] = [];
|
|
163
169
|
}
|
|
164
170
|
// store channels, stop it instead of sounds
|
|
165
|
-
|
|
171
|
+
this._activeSounds[sound.id].push(channel);
|
|
166
172
|
MovieClip._activeSoundsOwners.add(this);
|
|
167
173
|
};
|
|
168
|
-
MovieClip.prototype.stopSounds = function (
|
|
169
|
-
if (
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
this._sounds[soundID].stop();
|
|
173
|
-
delete this._sounds[soundID];
|
|
174
|
-
var channels = MovieClip._activeSounds[soundID];
|
|
175
|
-
if (channels) {
|
|
176
|
-
for (var _i = 0, channels_1 = channels; _i < channels_1.length; _i++) {
|
|
177
|
-
var c = channels_1[_i];
|
|
178
|
-
c.stop();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
delete MovieClip._activeSounds[soundID];
|
|
182
|
-
}
|
|
174
|
+
MovieClip.prototype.stopSounds = function (sound) {
|
|
175
|
+
if (sound === void 0) { sound = null; }
|
|
176
|
+
if (sound) {
|
|
177
|
+
this.stopSound(sound);
|
|
183
178
|
}
|
|
184
179
|
else {
|
|
185
|
-
for (var key in this._sounds)
|
|
186
|
-
this._sounds[key]
|
|
187
|
-
var channels = MovieClip._activeSounds[soundID];
|
|
188
|
-
if (channels) {
|
|
189
|
-
for (var _a = 0, channels_2 = channels; _a < channels_2.length; _a++) {
|
|
190
|
-
var c = channels_2[_a];
|
|
191
|
-
c.stop();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
delete MovieClip._activeSounds[key];
|
|
195
|
-
}
|
|
196
|
-
this._sounds = {};
|
|
180
|
+
for (var key in this._sounds)
|
|
181
|
+
this.stopSound(this._sounds[key]);
|
|
197
182
|
}
|
|
198
183
|
if (Object.getOwnPropertyNames(this._sounds).length === 0) {
|
|
199
184
|
MovieClip._activeSoundsOwners.delete(this);
|
|
@@ -203,13 +188,11 @@ var MovieClip = /** @class */ (function (_super) {
|
|
|
203
188
|
for (var i = 0; i < len; ++i) {
|
|
204
189
|
child = this._children[i];
|
|
205
190
|
if (child.isAsset(MovieClip))
|
|
206
|
-
child.stopSounds(
|
|
191
|
+
child.stopSounds(sound);
|
|
207
192
|
}
|
|
208
193
|
this.stopCurrentStream(this._currentFrameIndex);
|
|
209
|
-
|
|
210
|
-
if (this._soundStreams) {
|
|
194
|
+
if (this._soundStreams)
|
|
211
195
|
this._soundStreams.syncSounds(0, false, this.parent);
|
|
212
|
-
}
|
|
213
196
|
};
|
|
214
197
|
/**
|
|
215
198
|
* Compute scene index by global frame index
|
|
@@ -309,26 +292,21 @@ var MovieClip = /** @class */ (function (_super) {
|
|
|
309
292
|
enumerable: true,
|
|
310
293
|
configurable: true
|
|
311
294
|
});
|
|
312
|
-
MovieClip.prototype.stopSound = function (
|
|
313
|
-
if (this._sounds[id]) {
|
|
314
|
-
this._sounds[id].stop();
|
|
315
|
-
delete this._sounds[id];
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
295
|
+
MovieClip.prototype.stopSound = function (sound) {
|
|
296
|
+
if (this._sounds[sound.id]) {
|
|
297
|
+
this._sounds[sound.id].stop();
|
|
298
|
+
delete this._sounds[sound.id];
|
|
299
|
+
if (Object.getOwnPropertyNames(this._sounds).length === 0) {
|
|
300
|
+
MovieClip._activeSoundsOwners.delete(this);
|
|
301
|
+
}
|
|
302
|
+
var channels = this._activeSounds[sound.id];
|
|
303
|
+
if (channels) {
|
|
304
|
+
for (var _i = 0, channels_1 = channels; _i < channels_1.length; _i++) {
|
|
305
|
+
var c = channels_1[_i];
|
|
306
|
+
c.stop();
|
|
307
|
+
}
|
|
308
|
+
delete this._activeSounds[sound.id];
|
|
323
309
|
}
|
|
324
|
-
delete MovieClip._activeSounds[id];
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
MovieClip.prototype.stopAllSounds = function () {
|
|
328
|
-
var keys = Object.keys(this._sounds);
|
|
329
|
-
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
330
|
-
var k = keys_1[_i];
|
|
331
|
-
this.stopSounds(k);
|
|
332
310
|
}
|
|
333
311
|
};
|
|
334
312
|
MovieClip.prototype.buttonReset = function () {
|
|
@@ -734,13 +712,25 @@ var MovieClip = /** @class */ (function (_super) {
|
|
|
734
712
|
*/
|
|
735
713
|
_super.prototype.clear.call(this);
|
|
736
714
|
};
|
|
715
|
+
MovieClip.prototype.onSoundCompleteInternal = function (event) {
|
|
716
|
+
var channel = event.target;
|
|
717
|
+
var sound = channel.owner;
|
|
718
|
+
var channels = this._activeSounds[sound.id];
|
|
719
|
+
var index = channels.indexOf(channel);
|
|
720
|
+
if (index != -1) {
|
|
721
|
+
channels.splice(index, 1);
|
|
722
|
+
}
|
|
723
|
+
if (channels.length === 0)
|
|
724
|
+
delete this._sounds[sound.id];
|
|
725
|
+
if (Object.getOwnPropertyNames(this._sounds).length === 0)
|
|
726
|
+
MovieClip._activeSoundsOwners.delete(this);
|
|
727
|
+
};
|
|
737
728
|
//todo: this 3 are no longer used (?)
|
|
738
729
|
MovieClip.avm1ScriptQueue = [];
|
|
739
730
|
MovieClip.avm1ScriptQueueScripts = [];
|
|
740
731
|
MovieClip.avm1LoadedActions = [];
|
|
741
732
|
MovieClip.movieClipSoundsManagerClass = null;
|
|
742
733
|
MovieClip._movieClips = new Array();
|
|
743
|
-
MovieClip._activeSounds = {};
|
|
744
734
|
MovieClip._activeSoundsOwners = new Set();
|
|
745
735
|
MovieClip.assetType = '[asset MovieClip]';
|
|
746
736
|
return MovieClip;
|
package/index.ts
CHANGED
package/lib/base/Timeline.ts
CHANGED
|
@@ -481,17 +481,17 @@ export class Timeline {
|
|
|
481
481
|
for (let i: number = start_index; i < end_index; i++) {
|
|
482
482
|
const audioProps: any = this.audioPool[this.add_sounds_stream[i]];
|
|
483
483
|
if (audioProps) {
|
|
484
|
-
|
|
485
|
-
const child: WaveAudio = audioProps.sound;
|
|
484
|
+
const sound: WaveAudio = audioProps.sound;
|
|
486
485
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
486
|
+
if (!sound) {
|
|
487
|
+
console.warn('[Timeline] Missing sound in audioProps!', audioProps);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
491
490
|
|
|
492
|
-
|
|
491
|
+
if (audioProps.cmd == 15) {// start sound
|
|
492
|
+
target_mc.startSound(sound, audioProps.props.loopCount || 0);
|
|
493
493
|
} else if (audioProps.cmd == 16) {// stop sound
|
|
494
|
-
target_mc.stopSound(
|
|
494
|
+
target_mc.stopSound(sound);
|
|
495
495
|
}
|
|
496
496
|
//console.log("start sound:", child);
|
|
497
497
|
}
|
package/lib/display/MovieClip.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WaveAudio, IAudioChannel } from '@awayjs/core';
|
|
1
|
+
import { WaveAudio, IAudioChannel, EventBase } from '@awayjs/core';
|
|
2
2
|
import { PartitionBase, EntityNode } from '@awayjs/view';
|
|
3
3
|
import { IMovieClipAdapter } from '../adapters/IMovieClipAdapter';
|
|
4
4
|
import { Timeline } from '../base/Timeline';
|
|
@@ -8,6 +8,7 @@ import { DisplayObject } from './DisplayObject';
|
|
|
8
8
|
import { Sprite } from './Sprite';
|
|
9
9
|
import { DisplayObjectContainer } from './DisplayObjectContainer';
|
|
10
10
|
import { MouseButtons } from '../base/MouseButtons';
|
|
11
|
+
import { BaseAudioChannel } from '@awayjs/core/dist/lib/managers/BaseAudioChannel';
|
|
11
12
|
interface IScene {
|
|
12
13
|
offset: number;
|
|
13
14
|
name: string;
|
|
@@ -29,11 +30,10 @@ export class MovieClip extends Sprite {
|
|
|
29
30
|
public static movieClipSoundsManagerClass = null;
|
|
30
31
|
|
|
31
32
|
private static _movieClips: Array<MovieClip> = new Array<MovieClip>();
|
|
32
|
-
private static _activeSounds: Record<number, IAudioChannel[]> = {};
|
|
33
33
|
private static _activeSoundsOwners: Set<MovieClip> = new Set<MovieClip>();
|
|
34
34
|
|
|
35
35
|
public static stopAllSounds() {
|
|
36
|
-
MovieClip._activeSoundsOwners.forEach(e => e && e.
|
|
36
|
+
MovieClip._activeSoundsOwners.forEach(e => e && e.stopSounds());
|
|
37
37
|
MovieClip._activeSoundsOwners.clear();
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -86,7 +86,8 @@ export class MovieClip extends Sprite {
|
|
|
86
86
|
|
|
87
87
|
public _sessionID_childs: NumberMap<DisplayObject> = {};
|
|
88
88
|
|
|
89
|
-
private _sounds:
|
|
89
|
+
private _sounds: Record<number, WaveAudio> = {};
|
|
90
|
+
private _activeSounds: Record<number, IAudioChannel[]> = {};
|
|
90
91
|
|
|
91
92
|
public _useHandCursor: boolean;
|
|
92
93
|
|
|
@@ -196,6 +197,8 @@ export class MovieClip extends Sprite {
|
|
|
196
197
|
if (spriteMode) {
|
|
197
198
|
this.transformToSprite();
|
|
198
199
|
}
|
|
200
|
+
|
|
201
|
+
this.onSoundCompleteInternal = this.onSoundCompleteInternal.bind(this);
|
|
199
202
|
}
|
|
200
203
|
|
|
201
204
|
/**
|
|
@@ -225,52 +228,36 @@ export class MovieClip extends Sprite {
|
|
|
225
228
|
}
|
|
226
229
|
|
|
227
230
|
public startSound(
|
|
228
|
-
id: any,
|
|
229
231
|
sound: WaveAudio,
|
|
230
232
|
loopsToPlay: number,
|
|
231
|
-
|
|
233
|
+
onSoundComplete?: (event: EventBase) => void
|
|
232
234
|
) {
|
|
233
235
|
|
|
234
236
|
const channel: IAudioChannel = sound.play(0, loopsToPlay);
|
|
235
237
|
|
|
236
|
-
|
|
238
|
+
if (onSoundComplete)
|
|
239
|
+
channel.addEventListener(BaseAudioChannel.COMPLETE, onSoundComplete);
|
|
240
|
+
|
|
241
|
+
//internal listener to clear
|
|
242
|
+
channel.addEventListener(BaseAudioChannel.COMPLETE, this.onSoundCompleteInternal);
|
|
237
243
|
|
|
238
|
-
this._sounds[id] = sound;
|
|
244
|
+
this._sounds[sound.id] = sound;
|
|
239
245
|
|
|
240
|
-
if (!
|
|
241
|
-
|
|
246
|
+
if (!this._activeSounds[sound.id]) {
|
|
247
|
+
this._activeSounds[sound.id] = [];
|
|
242
248
|
}
|
|
243
249
|
|
|
244
250
|
// store channels, stop it instead of sounds
|
|
245
|
-
|
|
251
|
+
this._activeSounds[sound.id].push(channel);
|
|
246
252
|
MovieClip._activeSoundsOwners.add(this);
|
|
247
253
|
}
|
|
248
254
|
|
|
249
|
-
public stopSounds(
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
this._sounds[soundID].stop();
|
|
253
|
-
delete this._sounds[soundID];
|
|
254
|
-
|
|
255
|
-
const channels = MovieClip._activeSounds[soundID];
|
|
256
|
-
if (channels) {
|
|
257
|
-
for (const c of channels) c.stop();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
delete MovieClip._activeSounds[soundID];
|
|
261
|
-
}
|
|
255
|
+
public stopSounds(sound: WaveAudio = null) {
|
|
256
|
+
if (sound) {
|
|
257
|
+
this.stopSound(sound);
|
|
262
258
|
} else {
|
|
263
|
-
for (const key in this._sounds)
|
|
264
|
-
this._sounds[key]
|
|
265
|
-
|
|
266
|
-
const channels = MovieClip._activeSounds[soundID];
|
|
267
|
-
if (channels) {
|
|
268
|
-
for (const c of channels) c.stop();
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
delete MovieClip._activeSounds[key];
|
|
272
|
-
}
|
|
273
|
-
this._sounds = {};
|
|
259
|
+
for (const key in this._sounds)
|
|
260
|
+
this.stopSound(this._sounds[key]);
|
|
274
261
|
}
|
|
275
262
|
|
|
276
263
|
if (Object.getOwnPropertyNames(this._sounds).length === 0) {
|
|
@@ -282,15 +269,13 @@ export class MovieClip extends Sprite {
|
|
|
282
269
|
for (let i: number = 0; i < len; ++i) {
|
|
283
270
|
child = this._children[i];
|
|
284
271
|
if (child.isAsset(MovieClip))
|
|
285
|
-
(<MovieClip>child).stopSounds(
|
|
272
|
+
(<MovieClip>child).stopSounds(sound);
|
|
286
273
|
}
|
|
287
274
|
|
|
288
275
|
this.stopCurrentStream(this._currentFrameIndex);
|
|
289
|
-
MovieClip._activeSounds = {};
|
|
290
276
|
|
|
291
|
-
if (this._soundStreams)
|
|
277
|
+
if (this._soundStreams)
|
|
292
278
|
this._soundStreams.syncSounds(0, false, this.parent);
|
|
293
|
-
}
|
|
294
279
|
}
|
|
295
280
|
|
|
296
281
|
/**
|
|
@@ -392,28 +377,21 @@ export class MovieClip extends Sprite {
|
|
|
392
377
|
}
|
|
393
378
|
}
|
|
394
379
|
|
|
395
|
-
public stopSound(
|
|
396
|
-
if (this._sounds[id]) {
|
|
397
|
-
this._sounds[id].stop();
|
|
398
|
-
delete this._sounds[id];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
if (Object.getOwnPropertyNames(this._sounds).length === 0) {
|
|
402
|
-
MovieClip._activeSoundsOwners.delete(this);
|
|
403
|
-
}
|
|
380
|
+
public stopSound(sound: WaveAudio) {
|
|
381
|
+
if (this._sounds[sound.id]) {
|
|
382
|
+
this._sounds[sound.id].stop();
|
|
383
|
+
delete this._sounds[sound.id];
|
|
404
384
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
MovieClip._activeSounds[id][i].stop();
|
|
385
|
+
if (Object.getOwnPropertyNames(this._sounds).length === 0) {
|
|
386
|
+
MovieClip._activeSoundsOwners.delete(this);
|
|
408
387
|
}
|
|
409
|
-
delete MovieClip._activeSounds[id];
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
388
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
389
|
+
const channels = this._activeSounds[sound.id];
|
|
390
|
+
if (channels) {
|
|
391
|
+
for (const c of channels) c.stop();
|
|
392
|
+
|
|
393
|
+
delete this._activeSounds[sound.id];
|
|
394
|
+
}
|
|
417
395
|
}
|
|
418
396
|
}
|
|
419
397
|
|
|
@@ -887,6 +865,23 @@ export class MovieClip extends Sprite {
|
|
|
887
865
|
|
|
888
866
|
super.clear();
|
|
889
867
|
}
|
|
868
|
+
|
|
869
|
+
private onSoundCompleteInternal(event: EventBase): void {
|
|
870
|
+
const channel: IAudioChannel = event.target;
|
|
871
|
+
const sound = channel.owner;
|
|
872
|
+
const channels = this._activeSounds[sound.id];
|
|
873
|
+
const index = channels.indexOf(channel);
|
|
874
|
+
|
|
875
|
+
if (index != -1) {
|
|
876
|
+
channels.splice(index, 1);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (channels.length === 0)
|
|
880
|
+
delete this._sounds[sound.id];
|
|
881
|
+
|
|
882
|
+
if (Object.getOwnPropertyNames(this._sounds).length === 0)
|
|
883
|
+
MovieClip._activeSoundsOwners.delete(this);
|
|
884
|
+
}
|
|
890
885
|
}
|
|
891
886
|
|
|
892
887
|
PartitionBase.registerAbstraction(EntityNode, MovieClip);
|