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 ![]()

Nice. Did you create this class yourself?
Yes
Nice! And eerily similar to what something we’re using on our site (soon to launch)
I had a question about your as3 color component, it’d be great to email if you have a chance,
Is there an AS2 version of this class? D
Drewb: Theres really nothing as3 specific in the code, it should be a snap to convert.
Change the first line of the function to var g:MovieClip = target;
Then change the function header (so target is a MovieClip), and package stuff.
great example. I will use this one in future