Button Tooltip
| Category | : Flash | Views | : 19167 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : button-tooltip.zip | ||
| Result | : See the result | ||||
Code Explanation
btn1.onRollOver = function()
{
tooltipTimer = setInterval(showTooltip, 1000, "This is Button 1");
}
This code sets an interval that calls the function "showTooltip" every 1000 milliseconds with the parameter "This is Button 1".
setInterval(function name, milliseconds, parameters for the function);
The third parameter for setInterval is optional.Every setInterval returns an unique ID and this ID number is need if we want to stop calling the function "showTooltip".
Thatē“ why we used "tooltipTimer = ...;".
btn1.onRollOut = btn2.onRollOut = btn3.onRollOut = function()
{
_root.Tooltip._visible = false;
clearInterval(tooltipTimer);
}
On the RollOut event of all button set the visibility of the tooltip to false and use the function clearInterval to stop calling "showTooltip".
clearInterval(ID number);
function showTooltip(tip)
{
_root.Tooltip._visible = true;
Make Tooltip visible.
_root.Tooltip._x = _xmouse;
_root.Tooltip._y = _ymouse;
Set Tooltip position.
_root.Tooltip.tip.text = tip;
}
Set text for the tooltip.That's the end of the tutorial. Happy coding!
![]() |
![]() |
![]() |
![]() |
![]() |






