Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Chapter 14. Iteration and Repetition > Building a Dynamic Menu Using an Associa... - Pg. 192

Chapter 14 Building a Dynamic Menu Using an Associative Array Once you know how to iterate through the elements of an array using the for loop, you can move up to using an associative array (covered in Chapter 12). In this chapter, we'll use an associative array to store multiple pieces of information for buttons that we'll then use to create a menu with dynamic menu items. Using associative arrays, as well as the MovieClip , TextField , and MouseEvent classes, we will create a menu button that will be used repeatedly to add to a menu dynami- cally that has its own text label and properties. Figure 14.3 Ensure that the Selectable property for the text field is disabled so that it does not interfere with the button click. To build a reusable menu button class: 1. Draw a rectangle on the stage that would make a reasonably sized button for a menu list.