Previous Page
Next Page

Tripod >> 3pod Tips & Learning and manuals for educations

Recipe 15.5. Working with Color Styles

Problem

You want to apply a color style setting to a component or components.

Solution

Assign a value to the appropriate style using either a numeric value or one of the predefined color strings.

Discussion

There are a handful of styles that deal with color. Each of the color styles is discussed in slightly more detail in the appropriate recipe later in this chapter as they apply to specific components. However, regardless of which color style you are setting, you have two options for the value: one of the predefined color string values, or a numeric value (typically in hexadecimal format). The following color strings are recognized by Flash:

Table 15-1.

Color string

Hexadecimal value

Black

0x000000

Blue

0x0000FF

Cyan

0x00FFFF

Green

0x00FF00

Magenta

0xFF00FF

Red

0xFF0000

White

0xFFFFFF

Yellow

0xFFFF00


For example, if you want to apply a red value to the color style globally, you can use the following line of code:

	_global.style.setStyle("color", "red");

If you want to use a color value other than one of the predefined color strings, you can use numbers instead. Typically, you'll work with the numbers in hexadecimal format. In ActionScript, hexadecimal numbers are prefixed with 0x. For example, the hexadecimal representation for red is 0xFF0000. The following line of code is, therefore, the equivalent to the previous example:

	_global.style.setStyles("color", 0xFF0000);

Unless you happen to already know the hexadecimal value for the colors you want to use, you likely could use a little assistance from the computer. One simple way to get the hexadecimal value of a particular color within Flash is to use the Color Mixer panel. Open the Color Mixer panel (Window Design Panels Color Mixer) and select a color. The hexadecimal value is displayed in a text field in the lower-left corner of the panel. You can then copy that text field and paste the value into the appropriate part of your code in the Actions panel. Notice, however, that in the Color Mixer panel, Flash prefixes the value with a #. So make sure to make the appropriate change. For example, if you select a color in the Color Mixer panel for which Flash displays #634181 in the text field, you should copy just the 634181 portion, and then change that to 0x634181 in your ActionScript code.

Any style in which the name (exp 3pod.com) ends with either Color or color (e.g., borderColor)is a color style. So you can use the color strings or numeric values with those styles.

Additionally, there is one color style, themeColor, that accepts three extra color string values. With themeColor, you can use the regular color strings, numeric values, or one of the following three extra color strings: haloGreen, haloBlue, haloOrange.

Tripod >> 3pod Botom Tips & Learning and manuals for educations

Previous Page
Next Page

 

bluedot bluedots greydots pinkdots

Tripod >> 3pod Tips & Learning and manuals for educations