Creating "Float-Over" (QuickTip) Interactions

Sometimes, it is helpful or necessary to have a "quicktip" on a Web page, where when the user floats his or her mouse cursor over an image or block of text, a small window pops up with additional information. You can see examples of this throughout the Web, such as at many retail sites where floating the cursor over an image presents the user with a bigger version of the image to show detail.

Looking for an ActionScript 3 version of this tutorial? Check out:

 

To create a QuickTip interaction:

1. Once again, we will start with a new, blank ActionScript 2.0 document. Of course, it is not necessary to start with a new document and you can insert a quicktip interaction like the following into any Flash animation.

File menu - new window

New Document Actionscript 2

2. Use the New Layer button in the bottom left-hand corner of the timeline to create two layers in your document, one called "quicktip" and one called "action".

New Layer Button

QuickTip and Action layers in timeline

2. Now, click on Frame 1 of the quicktip layer and draw a shape, such as a rectangle, using the drawing tools. The purpose for this step is to create a button that will serve as the "hotspot," or the place where the quicktip will be triggered when the mouse rolls over it, so there is no need to do anything other than draw a simple shape at this point.

Draw a Button

3. Once you are satisfied with your button, right-click (or Control-click) on it to Convert it to a Symbol. You will want to change it to a button symbol - the name can be anything you like.

Convert to Symbol

Symbol Properties

4. Once you have changed the graphic into a button symbol, you must name this instance of that symbol by changing its name in the Properties window. Again, the name can match mine, or be anything you like. However, avoid the use of spaces or non-text characters other than underscores, numbers, or dashes, in your naming.

Naming the Button

5. Each button has four states in Flash - the up, over, down, and Hit states - as you may remember from other tutorials. These define how the button looks when it is being clicked, as well as what the clickable area of the button actually is. To set these states, use the Black Pointer tool and double-click on the button to go to its timeline.

Button States

6. For our QuickTip interaction, we need to create a hotspot that is actually invisible onscreen. To achieve this effect, click and drag the keyframe from the Up state to the Hit state. Your timeline will appear as shown below if you did this correctly.

Button States for Hotspot

7. Return to the main timeline by clicking Scene 1.

Change Scenes

8. Your button will now be a light blue color, and can be positioned on the stage wherever you may need it to be. You can even change the size of the hotspot if needed using the Free Transform tool.

Hotspot in stage

Free Transform Tool

9. Now, you will need to create a second shape on the quicktip layer, this time right-clicking on it and converting it to a Movie Clip Symbol. This symbol will become the placeholder for your quicktip text. Note that it does not matter where you position this shape on your stage - the position of this symbol will be dynamically set later on.

Movie Clip convert to symbol

10. Double-click on your Movie Clip symbol and choose the Text tool. Draw a box within your Movie Clip symbol for your text to go, and add some dummy text so you can see what text will look like within this area. Change the properties of your text style as needed, including:

  • Set the Text Box properties to Dynamic Text
  • Change the line type to Multiline
  • Click the Render Text as HTML widget, next to the line type popup menu
  • Be sure to give the instance a name, such as "quicktip_txt"

Text box in movie clip

Your text properties should look a lot like what you see above, and your text box should be aligned so that it is just inside the Movie Clip symbol.

Text box inside movie clip

11. Return to Scene 1, and single-click on your movie clip to bring up its properties once again. Be sure it is has a name, such as "quicktip_mc," before continuing on.

Change Scenes

QuickTip name

12. All that is left is to script the interaction. Open your Actions Window from the Window menu and make sure that you are adding actions to Frame 1 by looking to the left-hand sidebar. Add the following script, replacing any names of the movie clip symbol, the the text box within the movie clip, or the button as appropriate. In the example's case, the button was named btn1, the movie quick quicktip_mc, and the text box quicktip_txt.

QuckTip Actionscript

The script first stops the movie so that interaction by the user can be performed. Then, the script tells Flash to make the quicktip movie clip initially invisible (visible=false), so that it will not appear until the user rolls the mouse cursor over the hotspot button. When the user does this, the script tells Flash to make the movie clip visible at the current X and Y coordinates of the cursor, and to display the text, "This is a quicktip" inside the text box. The <b> and </b> surrounding the word "quicktip" is HTML code to make the typeface bold. This could easily be <i> for italic as well, although note that within this particular Flash operation, only rudimentary HTML tags like <b> and <i> can be used.

Finally, when the user rolls away from the hotspot button, the quicktip movie is told to become invisible once again. Try it in the example file below.