AS3 Dynamic Speech Bubble Snippet
The static method drawSpeechBubble in the file below uses the drawing API to draw a rounded rectangle based speech bubble with a dynamic point. The side the point is on moves depending on the relative position to the bubble. It looks best if you set the point to be fairly close to the actual rectangle.
Usage:
SpeechBubble.drawSpeechBubble(target:Sprite, rect:Rectangle, cornerRadius:Number, point:Point)
// Example:
var g:Graphics = graphics;
var m:Matrix = new Matrix();
m.createGradientBox(200,100,90*Math.PI/180,80,80);
g.clear();
g.lineStyle(2,0×888888,1,true);
g.beginGradientFill(GradientType.LINEAR, [0xe0e0e0, 0xffffff], [1,1], [1,0xff],m);
SpeechBubble.drawSpeechBubble(this, new Rectangle(80,80,200,100), 20, new Point(120,300));
g.endFill();
Sample (move mouse to change point position):
Download:
SpeechBubble.as
Apologies for any code messiness! I’m aware that you can create a dent in the corner.. it’s probably up to you to position the point sensibly so it doesn’t screw up ![]()

