AS3 ToolTip Class
Phil Chertok on September 24, 2009
11 Comments
One common element of many applications is the tool tip. Tool tips can be useful for clarifying interactions and giving more detailed descriptions of elements in an app. Unfortunately AS3 does not have any native tool tip class so we have had to create our own.
Our goal was to make our tool tip class as easy to use as possible. Because we use a very specific framework here at A51 our regular tool tip class is very much married to it. So we decided to strip out any attachments to our framework and to provide it to the community.
Using the class is fairly straightforward, somewhere in your application you simply need to pass a reference of the stage to the class by calling ToolTip.init( stage ); You can then call ToolTip.show( ‘My tool tip message here’) at any point in your app. Don’t forget to call ToolTip.hide() to make it disappear.
You can check out an example of the class in action here. You can download this example and the class itself here.


October 14th, 2009 @ 5:08 AM
Very nice tooltip imo, simplistic and easy to adjust. Already added a dropshadow and am currently trying to change the font to an embedded font in my swf.
Cheers!
October 14th, 2009 @ 1:31 PM
Thanks Sebastian. We’ve got it working here with embedded fonts, just thought we’d throw it out there for people in the most simple way possible.
June 16th, 2010 @ 11:07 AM
Any chance od seeing a sample with embedded fonts? I’m having a bit of trouble implementing this….
June 16th, 2010 @ 12:23 PM
We here use FlashDevelop which allows us to pull in the Flex SDK into our Flash projects. So when we compile, we actually compile with the Flex SDK as apposed to the Flash compiler. With, Flex, you can use the Embed directive like:
[Embed(source='arial.ttf', fontName = 'Arial', mimeType = 'application/x-font', unicodeRange="U+0041-U+005A")]
private var Arial:Class;
Hope that helps!
December 17th, 2010 @ 9:16 AM
Thank you for this nice Tooltip, it’s a very good base to add more stuff to, thanks!
January 28th, 2011 @ 7:53 PM
Great Job, just for me don’t works, I get error #1009 in ToolTip/followMouse()
January 29th, 2011 @ 8:30 AM
Miguel, can you post the complete stack trace and which version of Flash are you using? Also, double check your compilation settings and make sure that AS3 and >= FP9 is selected.
April 26th, 2011 @ 4:56 PM
Hi.
Very nice, easy to use tooltip…but for the love of God, have mercy and tell regular Flash as3 non-Flex people what they would have to do to use another font…?
Pleeeaaaase. I am new to as3.
Can u just specify a font in tooltip.as???
Help.
April 27th, 2011 @ 4:16 PM
This is what I have so far in order to be able to use an embedded font…
I have added these lines to the original tooltip.as
private function initTextField():void
{
_tip = new TextField();
var myformat:TextFormat = new TextFormat();
myformat.font = “Akkurat”;
_tip.embedFonts = true;
_tip.setTextFormat(myformat);
_tip.selectable = false;
_tip.mouseEnabled = false;
//_tip.wordWrap = true;
//_tip.multiline = true;
_tip.autoSize = TextFieldAutoSize.LEFT;
_tip.border = false;
//_tip.borderColor = 0xFFFFFF;
_tip.background = true;
_tip.backgroundColor = 0×999999;
_tip.textColor = 0xFFFFFF ;
addChild(_tip);
}
Not working , I get the following error codes:
1046: Type was not found or was not a compile-time constant: TextFormat.
1180: Call to a possibly undefined method TextFormat.
Anyone?
Some help….
Thanks.
April 27th, 2011 @ 10:37 PM
Sonia, you’ll need to add the font to your library. Then you can reference an instance of that font in your code. See here for a good walkthrough: http://tournasdimitrios1.wordpress.com/2010/09/11/using-embedded-fonts-with-the-flash-cs3-button-control/
July 4th, 2011 @ 10:24 AM
Thanks a bunch for this great class. It’s the best one I’ve found for minimalist, application-style tooltips. The web is spammed with over-the-top solutions..