15 When a menu item is created, it gets passed a reference to the image map. The key technique is to place graphics via the beginBitmapFill function. Whenever the original BitmapData is updated by loading a new image map, the graphics in the buttons are automatically updated by Flash.
16 For the TextField setup, it’s important to enable HTML and embed all the required fonts in the library. Each TextField is assigned the Style Sheet that is handled by StyleSheetHandler. Flash automatically updates all TextFields that reference this whenever that class loads in a new CSS file.
17 Each menu item receives its own data object which stores the button name and URLs to the Style Sheet and image map to load on a click. Grouping information as an object simplifies passing that object around to the elements in the panel that need to access it.
18 When an item is clicked, the menu notifies the Main.as class and supplies it with the information from that button. Main.as then instructs the ImageMap and the StyleSheetHandler classes to load the corresponding files. As soon as they are loaded, Flash updates the panel.
19 When a new style has loaded, you need to centre the text in the buttons. Each style uses a different font and font size, so in order for the text to be positioned correctly, the menu items must adjust the position based on the new settings.
20 When you have everything set up, publish Tutorial.fla. As you click on buttons, new graphics and text formatting get loaded in and completely change the style of the menu. The structure is set up so that Flash does most of the work for you.
Computer Arts September 2008