- Listening for Events
- Mouse Detection
- The SimpleButton Class
- Invisible Buttons
- Animated Buttons and the Movie Clip Symbol
- Complex Buttons
- Button-tracking Options
- Changing Button Behavior
- Creating Buttons Dynamically
- Keyboard Detection
- The Contextual Menu
- Creating Continuous Actions
- A Summary of Events
You can exploit the flexibility of Flash button symbols by defining only particular states. If you leave empty keyframes in all states except for the Hit state, you create an invisible button . An invisible button is not visible to the audience, yet still maintains a clickable hot spot. Invisible buttons are extremely useful for creating generic hotspots to which you can assign actions. By placing invisible button instances on top of graphics, you essentially have the power to make any area on the Stage react to the mouse pointer. For example, you can place several invisible buttons over a map graphic to create hidden hotspots .
When you drag an instance of an invisible button onto the Stage, you see the hit area as a transparent blue shape, which allows you to place the button precisely. When you choose Control > Enable Simple Buttons (Ctrl-Alt-B for Windows, Cmd-Option-B for Mac), the button disappears to show you its playback appearance.
To create an invisible button
- Choose Insert > New Symbol (Ctrl-F8 for Windows, Cmd-F8 for Mac).
The Create New Symbol dialog box appears.
- Type the symbol name of your button, choose Button as the Type, and click OK.
A new button symbol is created in the Library, and you enter symbol-editing mode.
- Select the Hit keyframe.
- Choose Insert > Timeline > Keyframe (F6).
A new keyframe is created in the Hit state.
- With the Hit keyframe selected, draw a generic shape that serves as the hotspot for your invisible button .
- Return to the main Timeline.
- Drag an instance of the symbol from the Library onto the Stage.
A transparent blue shape appears on the Stage, indicating the Hit state of your invisible button .
- Move, scale, and rotate the invisible button instance to cover any graphic.
When you choose Control > Enable Simple Buttons, the transparent blue area disappears, but your pointer changes to a hand to indicate the presence of a button.
- Give the button instance a name in the Properties inspector and assign an event listener for it in the Actions panel as described in the previous tasks.