Fix bug with zero adding a costume/sound at index 0

This commit is contained in:
Paul Kaplan 2018-06-05 11:46:52 -04:00
parent c2645f3da5
commit 9fce4d40d0

View file

@ -488,10 +488,10 @@ class RenderedTarget extends Target {
* @param {?int} index Index at which to add costume
*/
addCostume (costumeObject, index) {
if (index) {
this.sprite.addCostumeAt(costumeObject, index);
} else {
if (typeof index === 'undefined') {
this.sprite.addCostumeAt(costumeObject, this.sprite.costumes.length);
} else {
this.sprite.addCostumeAt(costumeObject, index);
}
}
@ -551,10 +551,10 @@ class RenderedTarget extends Target {
addSound (soundObject, index) {
const usedNames = this.sprite.sounds.map(sound => sound.name);
soundObject.name = StringUtil.unusedName(soundObject.name, usedNames);
if (index) {
this.sprite.sounds.splice(index, 0, soundObject);
} else {
if (typeof index === 'undefined') {
this.sprite.sounds.push(soundObject);
} else {
this.sprite.sounds.splice(index, 0, soundObject);
}
}