This is an archived tutorial from the kirupa.com legacy collection. It covers software that may no longer be available, but it is kept online because the ideas still hold up.
"What in the world is a hover caption? Must be another name Kirupa made up." Now that you mention it, I think I did make the name up. A hover caption is the text that appears when you hover your mouse over a command icon or button. When you hover over the Lock icon in the timeline (in Flash MX), you will see the caption "Lock/Unlock Layers" display next to your mouse cursor. The text that displays when you hover over certain sections is the hover caption.
If Flash MX, Windows, Word, and other applications can have hover captions display when the mouse rests over an icon or command, why can't our animations have hover captions in them. After all, if Microsoft can create that effect, we should be able to create that effect as well...right? YES!
Note
This tutorial is mainly kept for archival purposes. The more recent version of this tutorial can be found here: Hover Captions v2
This tutorial will teach you how to create a hover caption that displays when you hover over a button in Flash MX:
[ hover over the flash icons in the above animation to see the captions ]
The following steps will explain how to create the caption box that houses the blue rectangle and text:

[ notice the yellow rectangular box ]

[ insert another layer ]

[ the text box zoomed in at 200% ]

[ ensure dynamic text is selected in the drop-down menu ]

[ how your text properties panel should look like after completing step x ]

[ the scene 1 tab and blue left arrow ]
That concludes this major portion of our tutorial. I am sure you are tired and worn-out from all this Flashing. If you need to, don't hesitate to take a break. Once you are refreshed and ready for some more flashing, click the next section link below.
|
|
Displaying
Hover Captions - Page 2
Now, we are continuing the tutorial from page 1. We are at the point in the tutorial where the text box is complete. Now we need to find a way to have the text box follow the mouse and appear when the user hovers over the button. The text box should disappear if the mouse cursor goes outside the button field.
The following steps will show you how to make the text field follow your mouse:

[ the properties panel for the movie clip ]
startDrag(_root.caption, true);
onClipEvent (enterFrame) {
if (_root.x==1) {
this._alpha = 50;
} else {
this._alpha = 0;
}
}
[ don't worry, I will explain the code near the end of this tutorial ]
Now, we have the rectangle box hidden when we move the mouse around the animation. Of course, we want the rectangular box display when we hover over a button. To top that off, we need to have an appropriate caption displayed inside the rectangular box to make the text caption complete. The following steps will help you to achieve all of the aforementioned items:
on (rollOver) {
_root.x = 1;
_root.caption.words = "Word!";
}
on (rollOut) {
_root.x = 0;
_root.caption.words = " ";
}
_root.caption.words
= "Word!". The word, Word! will be
displayed when the mouse hovers over that button._root.caption.words to
something like, Greetings!, Howdy, Hello!, etc.You have technically completed a hover text caption. Aesthetically, there is one nitpicky detail you may want to change. When you preview the animation and hover over the button, have you noticed that the rectangle containing the text box has the tendency to go under the mouse and covering up a letter in the caption instead of staying clear of the text?
The following image should explain the point I am trying to convey to you:

[ notice how the mouse pointer covers up text in the first icon ]
To fix the positioning of the rectangular box containing the text field in relation to the mouse cursor, follow these steps:

[ notice the positioning cross hair is in the bottom-left of the rectangle ]
The next section covers how all of the code in the animation works to display a hover caption. You will find the final source download for this animation in the next section as well =)
|
|
|
Displaying
Hover Captions - Page 3
Now, we are continuing the tutorial from page 2. In this, the final page of this tutorial, I will explain each segment of code used in the animation and why it works the way it does.
startDrag(_root.caption, true);
The above line is used to drag the
hover caption rectangular box. The rectangular box is
actually a movie clip with the instance value,
caption. Hence, the code
refers to the actual location,
_root and the name of the instance,
caption. The True
signifies that the movie clip should lock mouse to
center.
on (rollOver) { _root.x = 1; _root.caption.words = "Hello!"; } on (rollOut) { _root.x = 0; _root.caption.words = " "; }
The above segment of code is what
makes the text caption appear and disappear. In
on (rollOver)I
am basically telling Flash to execute any commands when
the mouse rolls over the button.
In
_root.x
= 1; I am declaring on the fly a
variable stored on the main level, _root called x. I am
also initializing the variable x with a value of 1. In
the next line,
_root.caption.words =
"Hello!";
I am telling Flash to display the word
"hello" in the words text field.
If you remember, the rectangular
shaped movie clip is called caption. Inside that movie
clip is the text field called words. In order to
communicate to display text in the text field, we need
to go via the _root
level and then access the caption movie clip and end up
at the words text field.
In the next segment of code, I basically undo what I did in the first segment of code with the rollOver. I'm re-initializing the value of x on the main level to 0. In the next line, I am telling the text field to be blank with nothing more than one space.
| Ask Kirupa? |
Why, when the text field is
transparent do I go to the extreme of leaving a
empty space to hide what is already hidden?
The answer is, unlike movie clip objects, text field objects contain system generated data such as text. Text that is static can be modified by the user or Flash into any numerous forms including being made transparent. Because we are using Dynamic Text, Flash will not transparent the text in the text field. You may see the background become transparent and disappear, but the text will be bold and bright as ever. That is why I am telling Flash to leave a small blank space instead. You don't see text (unless you can discern spaces....which is just plain strange) and Flash does not get confused! Problem solved. The only other method would be to embed the font outline in the dynamic text field. Once the font has been embedded, you will get the transparency to work in the dynamic text field quite nicely. You can see that post in which this revelation was made by clicking here. |
onClipEvent (enterFrame) { if (_root.x==1) { this._alpha = 50; } else { this._alpha = 0; } }
In this code segment, I am telling the movie clip to continuously check for the following statements: does x equal one or does x equal something other than 1? If the x variable equals 1, the alpha of this - the movie clip - is 50. I selected the background to be partially transparent because it creates a nice translucent effect. If you read the Ask Kirupa in the above table, you will understand why the text does not become partially transparent.
In the button actions, I told Flash to make the variable x equal one when the mouse rolls over the button. The moment the variable x equals 1, the hover caption becomes partially transparent. The moment the user takes the cursor out of the mouse - making x equal 0 - the hover caption immediately becomes fully transparent. The text is not visible because I used the " " value for the text field (see Ask Kirupa? above).
I hope you were able to learn how to create hover captions in Flash MX. This is a really good navigational aid that adds points in the areas of coolness and usability.
|
|
|
Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.
Your support keeps this site going! 😇

:: Copyright KIRUPA 2026 //--