Friday, November 23, 2012

EasyTooltip - free AS3 tooltip library - DOWNLOAD and HOW TO USE

EasyTooltip is a free AS3 library for easy, quick, pretty, customizable and efficient tooltip management.

The library can be downloaded here (10 kB).

To implement it, simply add the "com" folder to the directory of your folder.

It is also very useful if your IDE has a nice feature which displays available methods and properties of the class you're working with. FlashDevelop has this feature, for instance.

To use, create an instance of the EasyTooltip class:

var tooltip:EasyTooltip = new EasyTooltip(stage, stage.stageWidth, stage.stageHeight, 3, 200);

The parameters are:

parent - Reference to the parent of tooltips - the container, which will contain the objects that will be rolled over.
parentWidth - Width of the parent.
parentHeight - Height of the parent.
smoothMovement - The movement smoothener - the bigger the value, the smoother the movement. 1 = no smoothment.
spawnDelay - Delay in milliseconds of how long the user has to hold their mouse over the object to invoke a tooltip.

After declaring the EasyTooltip instance, you can use all of its features, as listed and explained below.

You can customize the visual appearance of your tooltips by creating a TooltipStyle class instance and applying it to the EasyTooltip object using its setStyle() method:


I'll explain styling in details in the next tutorial, right now I'll focus on functionality.

To invoke a tooltip, you need to add a tooltip listener. A listener here is a DisplayObject that the user can roll over to invoke the tooltip. This can be anything that is displayed on stage - a MovieClip, a Sprite, a TextField, etc. Adding a listener is easy - just use the addListener() method of the EasyTooltip object. Specify the reference to the visual object and tooltip message as parameters:

tooltip.addListener(object1, "Hello! ");

Removing listeners is just as easy. Use the removeListener() method and just pass the reference to a listener:


If you want to get rid of all tooltips and remove the EasyTooltip completely, along with all its internal processes and the memory space it takes, use the kill() method.


Make sure you nullify or re-declare the object after killing it. Trying to use its functions after calling kill() method will result in class misbehaviour and/or errors.

I hope you find the class useful!

Thanks for reading! As I said, there's a tooltip styling tutorial coming up next!

No comments:

Post a Comment