ActionScript 3.0 (AS3) ToolTip for Flash 9 (CS3) programmers!

I’m learning Flash right now. My next few games are going to be built in Flash in order to help me learn, and then hopefully build a nice PBBG using Flash and a dedicated C++ based network server. Should be highly exciting!

Anyway, after scouring the net for an amazing amount of time, I could not find a ToolTip component for ActionScript 3.0 (AS3). Tons for 2.0, but if I am going to be working with Flash, I have to go with 3.0. It’s much nicer for a serious programmer, as well as people who just want to be on the cutting edge.

I pretty much gave up after a few hours of digging, and decided it was time to rewrite somebody else’s code. So the one I found is apparently originally written by “Versus”, then modified by Joseph Poidevin. No idea who they are, no idea how to give them proper credit, because I honestly can’t remember where I found the original, and I changed about 80% of the code so hell, it really doesn’t much matter. The only thing that’s important is their work helped me to write a ToolTip that’s slightly customizable.

The class is fairly basic right now, but it does its job and does it well. You can customize opacity, text alignment, and delay (time before ToolTip shows up). I planned to add more customizations to the thing, but so far I really haven’t had a need, and I’m big on adding features only when you see a real-world use for said features. (Yes, I am aware font customizations will be very useful, but until I need them, I don’t write them)

If you find anything you’d like to add to this, please don’t hesitate to tell me. I may not incorporate all changes, because I want this thing to stay simple, but I’ll certainly consider anything I see.

Without further ado, here it is: ToolTip.as, or a tarball with the directory structure if you’re just too lazy to build it yourself: tooltip.tgz

Example usage:

This is actual code that yours truly is using in an exciting new game that may or may not ever be finished:


ToolTip.init(stage, {textalign: 'center', opacity: 85, defaultdelay: 500});
ToolTip.attach(btninstructions, 'Learn how to play\nScraboggle!');
ToolTip.attach(btnstart, "Begin a game of scraboggle.");
ToolTip.attach(btn_scores, "View the best scores and words, and who got 'em!");

10 Replies to “ActionScript 3.0 (AS3) ToolTip for Flash 9 (CS3) programmers!”

  1. What am i doing wrong, i’m not too good with actionscript but this error comes up when i test the movie…

    5000: The class ‘Tooltip’ must subclass ‘flash.display.MovieClip’ since it is linked to a library symbol of that type.

  2. Hi, Shane Carmody, you must import the tooltip class into flash file. Did you do? then use: import com.nerdbucket.ToolTip;

    then you can use it.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.