From cbebc28307caaa9044ea460b3aa6613b9e799d90 Mon Sep 17 00:00:00 2001
From: Paul Kaplan <pkaplan@media.mit.edu>
Date: Thu, 14 Dec 2017 16:46:31 -0500
Subject: [PATCH] Return a promise to indicate when a costume has loaded.

Parallels the way the `addSound` method works. Needed to enable
selecting new assets automatically from GUI.
---
 src/virtual-machine.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/virtual-machine.js b/src/virtual-machine.js
index 1c8df4df9..92a8d9794 100644
--- a/src/virtual-machine.js
+++ b/src/virtual-machine.js
@@ -314,9 +314,10 @@ class VirtualMachine extends EventEmitter {
      * @property {number} rotationCenterX - the X component of the costume's origin.
      * @property {number} rotationCenterY - the Y component of the costume's origin.
      * @property {number} [bitmapResolution] - the resolution scale for a bitmap costume.
+     * @returns {?Promise} - a promise that resolves when the costume has been added
      */
     addCostume (md5ext, costumeObject) {
-        loadCostume(md5ext, costumeObject, this.runtime).then(() => {
+        return loadCostume(md5ext, costumeObject, this.runtime).then(() => {
             this.editingTarget.addCostume(costumeObject);
             this.editingTarget.setCostume(
                 this.editingTarget.sprite.costumes.length - 1