9.8. Building Menus with Buttons

Problem

You want to create menus such that you can press one button and then roll over and release on others.

Solution

Set all the button instances to track as menu items.

Discussion

The normal behavior for buttons is such that if you press one button (but don’t yet release) and then drag the mouse pointer over another button, the other button will not respond to the rollover event. And if you release on top of a button other than the one on which you first pressed, the release event will not be activated either. In many cases, this is the behavior that you want from your buttons. However, when working with buttons that compose menus, you may want to alter that behavior such that buttons in the menu respond to rollover and release events even if the user first pressed another button in the menu. This behavior is particularly important for pop-up menus in which the user has to press one button to expand the menu.

You can quickly modify the behavior of a button in this way by setting it to track as a menu item. With button symbol instances, you can choose this option from the Property inspector. If you select the button instance on the stage, you can choose Track as Menu Item from the tracking menu.

The preceding technique works for button symbol instances at authoring time. If you want to track movie clip symbols as menu items or if you want to perform the same task at runtime, you can use the trackAsMenu property. The trackAsMenu property is a property ...

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.