Modifying default style property values in a theme

The default style property values are provided by each theme in a class named Default. To change the defaults for a custom theme, create a new ActionScript class called Default in a package appropriate for your theme, and change the default settings as desired.

To modify default style values in a theme:

  1. Create a new folder for your theme in First Run/Classes/mx/skins.

    For example, create a folder called myTheme.

  2. Copy an existing Defaults class to your new theme folder.

    For example, copy mx/skins/halo/Defaults.as to mx/skins/myTheme/Defaults.as.

  3. Open the new Defaults class in an ActionScript editor.

    Flash users can open the file within Flash. Or, you can open the file in Notepad in Windows or SimpleText on the Macintosh.

  4. Modify the class declaration to reflect the new package.

    For example, our new class declaration is class mx.skins.myTheme.Defaults.

  5. Modify the style settings as desired.

    For example, change the default disabled color to a dark red.

    o.disabledColor = 0x663333;
    
  6. Save the changed Defaults class file.
  7. Copy an existing FocusRect class from the source theme to your custom theme.

    For example, copy mx/skins/halo/FocusRect.as to mx/skins/myTheme/FocusRect.as.

  8. Open the new FocusRect class in an ActionScript editor.
  9. Modify all references to the source theme's package to the new theme's package.

    For example, change all occurrences of "halo" to "myTheme."

  10. Save the changed FocusRect class file.
  11. Open the FLA file for your custom theme.

    This example uses MyTheme.fla.

  12. Open the library (Window > Library) and locate the Defaults symbol.

    In this example, it's in Flash UI Components 2/Themes/MMDefault/Defaults.

  13. Edit the symbol properties for the Default symbol.
  14. Change the AS 2.0 Class setting to reflect your new package.

    The example class is mx.skins.myTheme.Defaults.

  15. Click OK.
  16. Locate the FocusRect symbol.

    In this example, it's in Flash UI Components 2/Themes/MMDefault/FocusRect.

  17. Edit the symbol properties for the FocusRect symbol.
  18. Change the AS 2.0 Class setting to reflect your new package.

    The example class is mx.skins.myTheme.FocusRect.

  19. Click OK.
  20. Apply the custom theme to a document by following the steps in the next section. (See Applying a new theme to a document.)

    Remember to include the Defaults and FocusRect symbols when dragging assets from your custom theme to the target document.

In this example you used a new theme to customize the text color of disabled components. This particular customization, changing a single default style property value, would have been accomplished more easily through styling as explained in Using styles to customize component color and text. Using a new theme to customize defaults is appropriate when customizing many style properties or when already creating a new theme to customize component graphics.


Flash CS3