mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Fixed ask prompting multiple times for the same script
This commit is contained in:
parent
ab25a08ef4
commit
efd46002bf
3 changed files with 8 additions and 2 deletions
|
@ -81,6 +81,8 @@ public class Interpreter {
|
|||
private var warpThread:Thread; // thread that is in warp mode
|
||||
private var warpBlock:Block; // proc call block that entered warp mode
|
||||
|
||||
public var askThread:Thread; // thread that opened the ask prompt
|
||||
|
||||
protected var debugFunc:Function;
|
||||
|
||||
public function Interpreter(app:Scratch) {
|
||||
|
@ -170,6 +172,7 @@ public class Interpreter {
|
|||
var wasRunning:Boolean = false;
|
||||
for (var i:int = 0; i < threads.length; i++) {
|
||||
if ((threads[i].topBlock == b) && (threads[i].target == targetObj)) {
|
||||
if (askThread == threads[i]) app.runtime.clearAskPrompts();
|
||||
threads[i] = newThread;
|
||||
wasRunning = true;
|
||||
}
|
||||
|
|
|
@ -306,12 +306,12 @@ public class SensingPrims {
|
|||
var obj:ScratchObj = interp.targetObj();
|
||||
if (obj) app.runtime.showVarOrListFor(interp.arg(b, 0), true, obj);
|
||||
}
|
||||
|
||||
|
||||
private function primHideListWatcher(b:Block):* {
|
||||
var obj:ScratchObj = interp.targetObj();
|
||||
if (obj) app.runtime.hideVarOrListFor(interp.arg(b, 0), true, obj);
|
||||
}
|
||||
|
||||
|
||||
private function primTimestamp(b:Block):* {
|
||||
const millisecondsPerDay:int = 24 * 60 * 60 * 1000;
|
||||
const epoch:Date = new Date(2000, 0, 1); // Jan 1, 2000 (Note: Months are zero-based.)
|
||||
|
|
|
@ -462,6 +462,7 @@ public class ScratchRuntime {
|
|||
|
||||
public function showAskPrompt(question:String = ''):void {
|
||||
var p:AskPrompter = new AskPrompter(question, app);
|
||||
interp.askThread = interp.activeThread;
|
||||
p.x = 15;
|
||||
p.y = ScratchObj.STAGEH - p.height - 5;
|
||||
app.stagePane.addChild(p);
|
||||
|
@ -469,6 +470,7 @@ public class ScratchRuntime {
|
|||
}
|
||||
|
||||
public function hideAskPrompt(p:AskPrompter):void {
|
||||
interp.askThread = null;
|
||||
lastAnswer = p.answer();
|
||||
p.parent.removeChild(p);
|
||||
app.stage.focus = null;
|
||||
|
@ -484,6 +486,7 @@ public class ScratchRuntime {
|
|||
}
|
||||
|
||||
public function clearAskPrompts():void {
|
||||
interp.askThread = null;
|
||||
var allPrompts:Array = [];
|
||||
var uiLayer:Sprite = app.stagePane.getUILayer();
|
||||
var c:DisplayObject;
|
||||
|
|
Loading…
Reference in a new issue