Chapter 15. Customizing UI Components

The Flash UI components provide you with a set of functional controls that take mere minutes to implement. These components are great time-savers—consider how long it can take to create something as seemingly simple as a combo box. However, these components have the same default look. With just a little bit of knowledge and code, you can quickly customize these components. This chapter explains how to programmatically style your components and how to create new artwork for your components.

15.1. Applying Individual Component Styles

Problem

You want to change the styles for a single component instance.

Solution

Call the setStyle( ) method for the component instance.

Discussion

Each of the UI components (combo box, checkbox, list, text input, and so on) has an ActionScript method named setStyle( ). Using setStyle( ), you can programmatically tell Flash to change many aspects of the component’s appearance. There are many styles that you can change using the setStyle( ) method, as discussed in the recipes throughout this chapter. However, regardless of which style you want to change, the same basic syntax applies:

componentInstanceName.setStyle(styleName, styleValue);

One of the styles that can be applied to all of the UI components is a style called themeColor. There are three preset values for themeColor (haloGreen, haloBlue, and haloOrange), as you can read in Recipe 15.5. The following code shows how you can apply a new themeColor value to a button component ...

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.