Recipe 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 instance named cbtSubmit:

 cbtSubmit.setStyle("themeColor", "haloOrange");   

If you want to apply just one or two styles to a single component instance, the setStyle( ) technique described in this recipe will be ideal. However, if you want to apply many styles to the instance, or if you want to apply the same styles to more than one component instance, consider the other techniques that are discussed in detail in the following three recipes.




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net