martedì, luglio 22, 2008

ActionScript 3 Tool Tips

Devon’s blog at onebyonedesign.com has a terrific ActionScript 3 class for generating “tool tips.” It’s part of a UI package that he generously makes available for free. (He discusses it a little in the Kirupa forums, too.) Here’s an extremely simple version:

import flash.display.Sprite;
import com.onebyonedesign.ui.OBO_ToolTip;
import flash.events.MouseEvent;

var _toolTip:OBO_ToolTip;

_toolTip = OBO_ToolTip.createToolTip(this, new LibraryFont(), 0x000000, .8, OBO_ToolTip.ROUND_TIP, 0xFFFFFF, 12, false);

yourmc.addEventListener(
MouseEvent.MOUSE_OVER,
function(evt:MouseEvent):void {
trace("hover!");
_toolTip.addTip("Hello");
}
);

yourmc.addEventListener(
MouseEvent.MOUSE_OUT,
function(evt:MouseEvent):void {
trace("Bye!");
_toolTip.removeTip();
}

);