diff --git a/src/serialization/sb2.js b/src/serialization/sb2.js index 9ca378d90..ffde8220a 100644 --- a/src/serialization/sb2.js +++ b/src/serialization/sb2.js @@ -420,7 +420,7 @@ const parseScratchObject = function (object, runtime, extensions, topLevel, zip) // followed by the file ext const assetFileName = `${soundSource.soundID}.${ext}`; soundPromises.push(deserializeSound(sound, runtime, zip, assetFileName) - .then(() => loadSound(sound, runtime))); + .then(() => loadSound(sound, runtime, sprite))); } } diff --git a/src/sprites/sprite.js b/src/sprites/sprite.js index c7c35c9e0..bc61960a0 100644 --- a/src/sprites/sprite.js +++ b/src/sprites/sprite.js @@ -155,7 +155,7 @@ class Sprite { newSprite.sounds = this.sounds.map(sound => { const newSound = Object.assign({}, sound); const soundAsset = this.runtime.storage.get(sound.assetId); - assetPromises.push(loadSoundFromAsset(newSound, soundAsset, this.runtime)); + assetPromises.push(loadSoundFromAsset(newSound, soundAsset, this.runtime, this)); return newSound; }); diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 9e93b79d2..57ae97e76 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -495,7 +495,7 @@ class VirtualMachine extends EventEmitter { duplicateSound (soundIndex) { const originalSound = this.editingTarget.getSounds()[soundIndex]; const clone = Object.assign({}, originalSound); - return loadSound(clone, this.runtime).then(() => { + return loadSound(clone, this.runtime, this.editingTarget.sprite).then(() => { this.editingTarget.addSound(clone, soundIndex + 1); this.emitTargetsUpdate(); }); @@ -966,8 +966,8 @@ class VirtualMachine extends EventEmitter { shareSoundToTarget (soundIndex, targetId) { const originalSound = this.editingTarget.getSounds()[soundIndex]; const clone = Object.assign({}, originalSound); - return loadSound(clone, this.runtime).then(() => { - const target = this.runtime.getTargetById(targetId); + const target = this.runtime.getTargetById(targetId); + return loadSound(clone, this.runtime, target.sprite).then(() => { if (target) { target.addSound(clone); this.emitTargetsUpdate();