mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Merge pull request #251 from LLK/bubble_hide_fix
Fix hiding the 'say' bubble WRT number formatting
This commit is contained in:
commit
9b83662450
4 changed files with 12 additions and 9 deletions
|
@ -157,13 +157,12 @@ public class LooksPrims {
|
|||
if (interp.activeThread.firstTime) {
|
||||
text = interp.arg(b, 0);
|
||||
secs = interp.numarg(b, 1);
|
||||
s.showBubble(text, type);
|
||||
s.showBubble(text, type, b);
|
||||
if (s.visible) interp.redraw();
|
||||
interp.startTimer(secs);
|
||||
} else {
|
||||
if (interp.checkTimer()) {
|
||||
text = interp.arg(b, 0);
|
||||
if (s.bubble && (s.bubble.getText() == text)) s.hideBubble();
|
||||
if (interp.checkTimer() && s.bubble && (s.bubble.getSource() == b)) {
|
||||
s.hideBubble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +177,7 @@ public class LooksPrims {
|
|||
} else { // talk or think command
|
||||
text = interp.arg(b, 0);
|
||||
}
|
||||
s.showBubble(text, type);
|
||||
s.showBubble(text, type, b);
|
||||
if (s.visible) interp.redraw();
|
||||
}
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ public class ScratchSprite extends ScratchObj {
|
|||
|
||||
/* talk/think bubble support */
|
||||
|
||||
public function showBubble(s:*, type:String, isAsk:Boolean = false):void {
|
||||
public function showBubble(s:*, type:String, source:Object, isAsk:Boolean = false):void {
|
||||
hideBubble();
|
||||
if (s == null) s = 'NULL';
|
||||
if (s is Number) {
|
||||
|
@ -569,7 +569,7 @@ public class ScratchSprite extends ScratchObj {
|
|||
}
|
||||
if (!(s is String)) s = s.toString();
|
||||
if (s.length == 0) return;
|
||||
bubble = new TalkBubble(s, type, isAsk ? 'ask' : 'say');
|
||||
bubble = new TalkBubble(s, type, isAsk ? 'ask' : 'say', source);
|
||||
parent.addChild(bubble);
|
||||
updateBubble();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class TalkBubble extends Sprite {
|
|||
private var style:String; // 'say' or 'ask' or 'result'
|
||||
private var shape:Shape;
|
||||
private var text:TextField;
|
||||
private var source:Object;
|
||||
private static var textFormat:TextFormat = new TextFormat(CSS.font, 14, 0, true, null, null, null, null, TextFormatAlign.CENTER);
|
||||
private static var resultFormat:TextFormat = new TextFormat(CSS.font, 12, CSS.textColor, null, null, null, null, null, TextFormatAlign.CENTER);
|
||||
private var outlineColor:int = 0xA0A0A0;
|
||||
|
@ -42,9 +43,10 @@ public class TalkBubble extends Sprite {
|
|||
private var pDropX:int = 8;
|
||||
private var lineWidth:Number = 3;
|
||||
|
||||
public function TalkBubble(s:String, type:String, style:String) {
|
||||
public function TalkBubble(s:String, type:String, style:String, source:Object) {
|
||||
this.type = type;
|
||||
this.style = style;
|
||||
this.source = source;
|
||||
if (style == 'ask') {
|
||||
outlineColor = 0x4AADDE;
|
||||
} else if (style == 'result') {
|
||||
|
@ -77,6 +79,8 @@ public class TalkBubble extends Sprite {
|
|||
|
||||
public function getText():String { return text.text }
|
||||
|
||||
public function getSource():Object { return source; }
|
||||
|
||||
private function setText(s:String):void {
|
||||
var desiredWidth:int = 135;
|
||||
text.width = desiredWidth + 100; // wider than desiredWidth
|
||||
|
|
|
@ -506,7 +506,7 @@ public class GestureHandler {
|
|||
|
||||
public function showBubble(text:String, x:Number, y:Number, width:Number = 0):void {
|
||||
hideBubble();
|
||||
bubble = new TalkBubble(text || ' ', 'say', 'result');
|
||||
bubble = new TalkBubble(text || ' ', 'say', 'result', this);
|
||||
bubbleStartX = stage.mouseX;
|
||||
bubbleStartY = stage.mouseY;
|
||||
var bx:Number = x + width;
|
||||
|
|
Loading…
Reference in a new issue