Here is another class that I just wrote which creates a tooltip using the drawing API. All you do is create a single instance and then use the “showTip()” method to show it and change the text. You send the fill and stroke colors in hex format to the constructor. See the usage below:
[as]var tt:Tooltip = new Tooltip(0xFFFFEC,0×000000);
butt1.onRollOver = function() {
tt.showTip(“Button 1 Tip”);
}
butt1.onRollOut = function() {
tt.removeTip();
}[/as]
See below for an example:
You can download the class here.
Lee








Hi. Interesting one. There is the one I wrote and use.
. http://versus.europin.org/examples/ToolTip.rar
Wow yours is much more in-depth! Very cool stuff. Thanks for sharing.
Lee
The rollover would be a little smoother if you used an onMouseMove method instead of onEnterFrame, and included an updateAfterEvent(). Then you don’t need the ‘delete onEnterFrame’ part either. In other words…
this.theTip.onMouseMove = function() {
this._x = _root._xmouse-15 ;
this._y = _root._ymouse-35;
updateAfterEvent();
}
Oleg, can You give some example of use your class as Lee did. Thanks
Yeah when I looked in Oleg’s class I saw that that’s the way he implemented it. His is structured a lot better than mine is. I’m just starting to dive into OOP with AS so I thank everyone for their input
Lee
Ok I’ve changed it to using the onMouseMove event and it is much smoother.
Thanks Todd,
Lee
example:
save the Class in the correct folder structure (versus/controls)
————————————
import versus.controls.ToolTip
// creates one instance of a tool tip
ToolTip.getInstance();
btn1.onRollOver = function() {
ToolTip.show(“Button 1 Tipfdsf“);
}
btn1.onRollOut = function() {
ToolTip.hide();
}
i’ve edited ‘private static function init()’ to give multilined ablity and changed the movieclip name of tooltip:
line 174 add:
label.multiline = true;
line 161 changed:
_cont = _root.createEmptyMovieClip ( ‘__tooltip_mc’, 9000 );
great work Oleg! thanks p;)
hi,
I have modified the ToolTip Class from Oleg. It’s a little more easy to use it.
you can download it from this page : http://bigcrunch.free.fr/dotclear/tb.php?id=5
Jo
As a late addition to Jo’s modification. Multi line only works if existing content is oken up into lines. But if we add:
label._width = (some number here as a maxWidth);
label.wordWrap = true;
then the label will resize as you would expect without having to manipulate the data that goes into the label. (so if the string is long, it will wrap after 100px, flash will find the nearest space to the said px distance, so it wont chop words in half unless they are longer than 100px.
BTW, all that contributed, thanks!
sorry, that code goes into the init() function. and the BR tag got axed in my comment. Mod please fix thanks
is there a way to load the tooltip content from an external file? xml, txt, etc
i have used the top method, works fine, however the width of the box is not big enough to fit in the text, i have extended the box but the text does not expand with it? help
don’t forget onReleaseOutside(){}
if you click on a button, hold down, and release outside of the button, the onRollOut event is never called
agreed Mark.
I’ve been having the problem of clicking on custom flash buttons, holding down, then moving off the button and releasing, for a while, and only just thought of using onreleaseoutside(), works perfectly!
so many websites with flash buttons have this problem (even profressional ones!). I guess the thing is, is that it’s not a very common problem, and often goes unnoticed. It’s only when a user clicks on a button and accidentally jerks the mouse off of the button that this problem is usualy noticed.
Jo,
Thanks for you tooltip class, it worked beautifully. However, a lot of users are getting a warning saying that a script is causing flash to run slowly – and it is the tooltip that is causing it. Unfortunately, my machine copes with it fine making it difficult to isolate the problem. Has anyone else noticed anything (I am assuming it relates to the interval since that message is usually given when using setInterval, infinite loops or onEnterFrame with too much code.
Any help appreciated.
Sorry people, nothing wrong with the code. I had added an alpha tween to fade the tooltip in and out and it caused performance problems on slower machines.
Thanks
Brian,
Do you have that code for the fading tooltip? I tried to add it, but it makes the tooltip act a little buggy:
When going from one button to another quickly, the tooltip for the next button won’t show up until.
Any help is much appreciated.
The links for oleg’s class and its modified versions are broken. Can someone upload it?
it’s giving an error
**Error** Scene=Scene 1, layer=actions, frame=1:Line 1: The class or interface ‘Tooltip’ could not be loaded.
var tt:Tooltip = new Tooltip(0xFFFFEC,0×000000);
Total ActionScript Errors: 1 Reported Errors: 1
Hi,
Work fine. But if you are near the right border of the clip the tooltip is not shown completely.
I’m working on it
It works good. What can I do to use multi-lines?
.onRollOver = function() {
tt.showTip(“first line\n”+”second line”);
}
Thank you, great class
Love the class! Works great and easy to implement. Only problem is I have dynamically generated movie clips for some buttons and it gets stuck behind them. I can’t figure out how to get the tooltip to show up in front of them.
http://www.customtiedye.com/colors.htm
If you don’t check this often, just go to the main page
http://www.customtiedye.com/
and browse around for the app. You’ll know it when you see it. Any help is appreciated. Maybe some way to get the depth of the mc that has the Tooltip and add 1 to it?
Thanks tons for making this class!
Mike
Say the class works nice. Had multi line working, but I would love to add an image in dynamically. I can’t seem to make it work. I seen other components doing it, but wondered if this one (that we implemented) can do it.
Anyone get a dynamically pulled image to show up?
Thanks!
I found this class very useful…Thanks! You can add a drop shadow very easily by including this to the beginning of your Tooltip.as file:
import flash.filters.DropShadowFilter;
Then add this to the Tooltip function:
var shadow = new DropShadowFilter(3, 45, 0×000000, 0.4, 5, 5, 1, 2);
…
this.theTip.filters = [shadow];
Thanks again Lee!
Just a quick note that Jo’s modified version of Olegs tooltip can be found here:
http://bigcrunch.free.fr/dotclear/index.php?q=tooltip
Don’t worry, the code is all in english! Just download the file at the bottom of the page.
Thanks to everyone for the work on this, it works great
hello…
Today i was on as.org and somebody ask about some problem with ‘his’ class.
I have replied and added some extra features to the tip.
zip
thread
Thanks for the class
sorry, this is the updated version
zip updated
Thank you for your updated actionscript tooltip, Pepe. I have been trying to use it however I cannot open your zip. When I try to load the Flash FLA, it says “Unexpected File Type”! I simply need to know how to call the tooltip in my main actionscript :
var tt:Tooltip = new Tooltip(???);
If anyone could help me, I’d be grateful!!!
Thank you-
Hi, i’m new to flash, and i want to create a tooltip for an area map. I’ve made to map and created all the different layers for each area, but now i’m not sure what to do next (i’m nt very clued up on actionscript)????? please help!
Thank you for sharing, i was a bit lost.
daniel
I stumbled across this when searching for tips on tooltips, and I have got the class that 3pepe3 posted and have it working well. After playing around with it I found that you can also add images within the tooltip via linking them from an online source, simply using the HTML tag. But the tooltip seems to only resize for the text, and doesn’t take into accound these images. Any tips on this would really help this already fantastic class! Cheers.
I downloaded and ran 3Pepe3′s test.swf, and find the test samples very interesting!
Unfortunately, I too cannot open the .fla file (I am using Flash 8 Professional).
I’d like to know how he masks the text inside of a cloud — it’s very cool.
Thanks,
– John
3Pepe3’s file is in Flash 9, so here is the code, just paste it in a Flash 8 file, and it will work :
———————-
import Tooltip.as;
var tipSquare = new Tooltip(“tip”, “tri”, 200);
var tipCloud = new Tooltip(“cloud”, “think”, 300);
var tipSquareBig = new Tooltip(“tip”, “tri”, 400);
butt1.onRollOver = function() {
tipSquare.showTip(“this is my very long text to test the wrapping of the textfield, we need to get the tooltip to resize the same height and width of the text.”);
};
butt1.onRollOut = function() {
tipSquare.removeTip();
};
butt2.onRollOver = function() {
tipCloud.showTip(“this is my text to test.”);
};
butt2.onRollOut = function() {
tipCloud.removeTip();
};
butt3.onRollOver = function() {
tipSquareBig.showTip(“this is my very long text to test the wrapping. this is my very long text to test the wrapping. this is my very long text to test the wrapping.”);
};
butt3.onRollOut = function() {
tipSquareBig.removeTip();
};
butt4.onRollOver = function() {
tipSquare.showTip(“this is my very long text to test the wrapping of the textfield, we need to get the tooltip to resize the same height and width of the text.”);
};
butt4.onRollOut = function() {
tipSquare.removeTip();
};
butt5.onRollOver = function() {
tipCloud.showTip(“this is a test”);
};
butt5.onRollOut = function() {
tipCloud.removeTip();
};
butt6.onRollOver = function() {
tipSquareBig.showTip(“this is my very long text to test the wrapping. this is my very long text to test the wrapping. this is my very long text to test the wrapping.”);
};
butt6.onRollOut = function() {
tipSquareBig.removeTip();
};
can somebody post 3Pepe3’s test.fla in a flash 8 format
PLEASE
I have added a update text function to update the text of the tooltip after it is created.
This is made for my open source flash graph application.
When the user rolls over the point, it shows the coordinate of the point and when the users drag the points, it continually updates the text with the new coordinates.
Very useful!
Thanks for sharing!
So, apparently this only works if you remove the strict compiler option from the publish settings. Perhaps it is my software engineering background, but it bothers me to do things the sloppy way, and from what I’ve been reading it would take a significant rewrite to do away with the _root references.
How do I convert this class to be action script 3 compatible?