From e3dfe24d7f8f2fae994fca87e6ca06911f7d55bd Mon Sep 17 00:00:00 2001 From: "Michael \"Z\" Goddard" Date: Fri, 3 Nov 2017 11:50:16 -0400 Subject: [PATCH] Store references to target in say blocks As part of reusing the block utility object, asynchronous say block functions cannot use the utility in a promise or timeout asynchronous handle. Store the needed target reference so utility is not needed later. --- src/blocks/scratch3_looks.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index df1a0246..399c6efa 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -245,11 +245,12 @@ class Scratch3LooksBlocks { sayforsecs (args, util) { this.say(args, util); + const _target = util.target; return new Promise(resolve => { this._bubbleTimeout = setTimeout(() => { this._bubbleTimeout = null; // Clear say bubble and proceed. - this._updateBubble(util.target, 'say', ''); + this._updateBubble(_target, 'say', ''); resolve(); }, 1000 * args.SECS); }); @@ -261,11 +262,12 @@ class Scratch3LooksBlocks { thinkforsecs (args, util) { this.think(args, util); + const _target = util.target; return new Promise(resolve => { this._bubbleTimeout = setTimeout(() => { this._bubbleTimeout = null; // Clear say bubble and proceed. - this._updateBubble(util.target, 'think', ''); + this._updateBubble(_target, 'think', ''); resolve(); }, 1000 * args.SECS); });