ToolTip Class
This is a simple tooltip class for adding tooltips to movie clips. 2005-06-28
This is a basic ToolTip ActionScript 2.0 class that allows you to add tooltips to any movie clip on stage. This class is very efficient, as it uses a singleton to manage and check all clips. The tooltip is completely skinnable, just create a clip with a linkage ID of 'ToolTipClip' and it will use that (see example .fla).
Example usage ( included in .fla ) :
import tv.ubergeek.iface.ToolTip;
toolTip = ToolTip.getInstance();
toolTip.addClip(clip1,"ToolTip");
toolTip.addClip(clip3.child,"This is clip 3.child");
toolTip.setDuration(500);
toolTip.removeClip(clip1);
This class works without using onRollOver and onRollOut events, but instead uses hitTest and a variety of other tests to determine 'tooltip time'. This is very useful because you can place a tooltip within a movieclip that already has a tooltip, and the parent's onRollOver event won't 'eat' the child's onRollOver event.
Naturally, using such an unorthodox approach means that there are problems. The main problem is that it is not possible to determine whether something is masked or not. And so even if something is masked, it will still display a tooltip. (very bad). This can be worked around by using onRollOver events in conjunction with the tooltip class a la:
function onRollOver(){
ToolTip.getInstance().addClip(this,"I am a tooltip");
}
function onRollOut(){
ToolTip.getInstance().removeClip(this);
}
Not ideal, I know. This isn't my proudest code, but hopefully something that someone will find more useful than their existing method.
Alas, this is code that I will hopefully re-write( or even better someone else will :P ) in AS3 and we'll never have to worry about this ever again.
Download the ToolTip class and example code.
[UPDATE August 10, 2006]The class now always creates tips on _level0, and expects the 'ToolTipClip' symbol to be in _level0. This works much better with loaded movies. If you change the tooltip text for a clip while the tooltip is being displayed, the text will update. ClipUtilities has had a lot of changes/upgrades, some of which completely unrelated.
|