Button Tooltip

Category : Flash Views : 14561
Version : 8 Rating
2.6/5 (32 votes)
Type : Text Source File: button-tooltip.zip
Result: See the result


Previous | 1 | 2 | Next

In this tutorial you will learn a simple tooltip code to use in any kind of flash application.

This is the result for this tutorial:
Free Flash Tutorials, Button, Tooltip

Create three buttons and drag them to the stage. Give the instance names "btn1", "btn2", "btn3", etc.

You can create one button, duplicate it two times and just change the text.

Now create a new Movie Clip and draw you tooltip:
Free Flash Tutorials, Button, Tooltip

On the top of your tooltip draw a dynamic text box with the instance name "tip", we will change the text later by using this name.
Free Flash Tutorials, Button, Tooltip

Go back to the main timeline and drag an instance of the Tooltip Movie Clip with the name "Tooltip".

Now go to the actions for the first frame and paste:
//when the mouse roll over btn1.onRollOver = function() { //explained bellow tooltipTimer = setInterval(showTooltip, 1000, "This is Button 1"); } btn2.onRollOver = function() { tooltipTimer = setInterval(showTooltip, 1000, "This is Button 2"); } btn3.onRollOver = function() { tooltipTimer = setInterval(showTooltip, 1000, "This is Button 3"); } //same event for all buttons btn1.onRollOut = btn2.onRollOut = btn3.onRollOut = function() { //hide the tool tip _root.Tooltip._visible = false; //clear the interval made on the roll over. clearInterval(tooltipTimer); } //function with the parameter "tip", tip is the text used in the tooltip function showTooltip(tip) { //tooltip is visible _root.Tooltip._visible = true; //set the tooltip position to be equal to the mouse. _root.Tooltip._x = _xmouse; _root.Tooltip._y = _ymouse; //set the text of the textbox inside the tooltip Movie Clip to the parameter "tip" _root.Tooltip.tip.text = tip; }

Test you code (Ctrl + Enter), leave you mouse over a button for at least one second to see the tooltip.


del.icio.us digg it Reddit Stumble Upon Technorati

Previous | 1 | 2 | Next




Supporters

Reseller Web Hosting