Advanced Color and Fills

Color is one of the most primitive and powerful communicative devices at your disposal. With color, a skillful animator can engender anxiety or peacefulness, hunger or confusion. She can jar, confuse, delight, soothe, entertain, or inform—all without saying a word.

Color theory is too large a topic to cover completely here. What you will find in this chapter is a quick introduction to basic color theory, as well as tips on how to work with color in Flash. You'll see how to change the colors of the shapes, lines, and images you create with Flash's drawing tools; how to create and reuse custom color palettes (especially useful if you're trying to match the colors in your Flash animation to those of a corporate logo, for example, or to a specific photo or piece of art); and how to apply sophisticated color effects including gradients, transparency, and bitmap fills.

The red you see in a nice, juicy watermelon—or any other color, for that matter—is actually made up of a bunch of different elements, each of which you can control using Flash's Color panel:

Color doesn't exist in a vacuum. The colors you get when you mix pigments aren't the same as the colors you get when you mix different-colored lights (which is how a computer monitor works). Artists working in oil paint or pastel use the red-yellow-blue color model, for example, and commercial printers use the cyan-magenta-yellow-black color model. In the world of computer graphics and animation, though, the color model you use is red-green-blue, or RGB.

This model means you can tell Flash to display any color imaginable just by telling it precisely how much red, green, and blue to display. But if you don't happen to know how much red, green, and blue make up, say, a certain shade of lilac, Flash gives you three more ways to specify a particular color:

In the next section, you'll see how to specify a custom color using Flash's Color panel.

Out of the box, Flash has 216 web-safe colors. But if you can't find the precise shade you want among those 216 colors, you're free to mix and match your own custom colors using Flash's Color panel.

Here's how:

  1. Select Window→Color.

    The Color panel shown in Figure 5-38 appears with the Color tab selected.

  2. On the Color tab, click either the Fill icon or the Stroke icon, depending on whether you plan to apply your custom color to a fill or a stroke.

    Drawing a Shape gives you the lowdown on the difference between the two.

  3. Select a custom color. You can do this one of these ways:

  4. To customize your color even further, you can use the drop-down menu to specify one of the following:

    Color type. Choose from Solid (what you want most of the time), Linear (a type of gradient effect described on Applying a Gradient), Radial (another type of gradient also described on Applying a Gradient), and Bitmap (lets you color an object using an image rather than a hue, as on Using an Image As a Fill "Color").

  5. To change the opacity (transparency) of your color, change the percentage in the A setting.

    Zero percent tells Flash to make your color completely transparent (see-through); 100% tells Flash to make your color completely opaque (Figure 5-39).

  6. In the Tools panel, select a drawing tool, and then begin drawing on the stage.

    Your strokes (or fills, depending on which icon you selected in step 1) appear in your brand-new custom color.

ActionScript is Flash's programming language. As you'll learn in later chapters, you can use ActionScript to automatically perform the same tasks that you do by hand—including specify colors. Suppose your animation is selling cars. Using ActionScript, you can let your audience change a car's color with the click of a button. ActionScript uses the RGB color system described in the previous section, but identifies individual colors using hexadecimal numbers. Hexadecimal numbers are base 16 instead of the base 10 numbers people use. (How's that for a flashback to math class?) The hexadecimal number system uses 16 symbols to represent numbers instead of the usual 0–9. When the common numeric symbols run out, hexadecimal uses letters. So, the complete set of number values looks like this: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

Hexadecimal RGB numbers use six places to describe each color. The first two numbers represent shades of the color red, the second two numbers represent shades of the color green, and the final two numbers represent shades of the color blue. So a color specification might look this: 0152A0. Or this: 33CCFF. At first, it seems odd to see the letters in numbers, but after a while you get the hang of it. So, the hexadecimal number FF0000 is a bright, pure red, while 0000FF is a bright blue. When you choose a color from a color picker, or Flash's Color panel (Window→Color) as shown in Figure 5-40, you're actually choosing an RGB color, whether you know it or not. Select a color, and then find the hexadecimal number in the box below.

You usually use the hexadecimal notation to specify RGB colors in ActionScript. Notice that the hexadecimal number in the color picker box is preceded by a pound sign (#), which is one common way to indicate that this is a hexadecimal number. (Not all hexadecimal numbers include letters, so this notation prevents hexadecimal numbers from being confused with regular numbers.) ActionScript code uses another method to indicate that a number is a hexadecimal number. In ActionScript, you precede all color codes with two characters: 0x. So, if you want to use the color shown in Figure 5-40 in your ActionScript code, you'd specify the color as 0xFF0000. You'll see plenty of other examples of specifying colors in ActionScript, starting with Chapter 12.

After you go to all the hard work of creating a custom color as described in the preceding section, you're probably going to want to save that color as a virtual swatch so you can reuse it again without having to try to remember how you mixed it.

To save a custom color swatch, first create a custom color, as described in the preceding section. You see your custom color displayed in the rectangle at the bottom of the Color panel. In the upper-right corner, click the panel's Options menu and choose Add Swatch. Your color is automatically added the Swatches panel. Click the Swatches tab and you see your new swatch at the bottom of the list next to the gradients, as shown in Figure 5-41.

After you've saved a custom swatch, you can use it to change the color of a stroke or a fill, as you see in Figure 5-42.

Instead of choosing or blending a custom color, you can select an image to use as a fill "color," as shown in Figure 5-42. You can select any image in Flash's Library panel (Properties subpanels), or from anywhere on your computer, and apply that image to any size or shape of fill to create some pretty interesting effects.

As you can see in the following pages, the result depends on both the size and shape of the fill and the image you choose.

To use an image as a fill color:

  1. Select all the fills you want to "color."

    Figure 5-43 shows an example of two fills: a star, and a free-form fill created using the Brush.

  2. In the Color panel, click the arrow next to Type, and then, from the drop-down list that appears, choose Bitmap (Figure 5-43).

    Flash displays the Import to Library window (Figure 5-44).

  3. In the Import to Library window, select the image file you want, and then click Open.

    Flash displays the image in the bottom of the Color panel, as well as next to the Fill icon, and "paints" your image with the bitmap. You can apply the bitmap to both fills and strokes, as shown in Figure 5-42. If your fill is larger than your image, Flash tiles the image (Figure 5-45).

A gradient is a fill coloring effect that blends bands of color into one another. Flash has linear gradients (straight up-and-down, left-to-right bands of color) and radial gradients (bands of color that begin in the center of a circle and radiate outward).

By applying a gradient to your fills, you can create the illusion of depth and perspective. For example, you can make a circle that looks like a sphere, a line that looks like it's fading, and text that looks like it's reflecting light (Figure 5-46).

You can apply a gradient swatch to your fills, or you can create your own custom gradients in Flash, much the same way you create your own custom colors (RGB and HSB).

To apply a gradient swatch to an object:

  1. On the stage, select the object to which you want to add a gradient.

    Flash highlights the selected object.

  2. Click the Fill Color icon.

    Flash displays the color picker (Figure 5-47).

  3. From the color picker, choose one of the seven gradient swatches that come with Flash.

    Flash automatically displays your object using the gradient swatch you chose. Figure 5-47 shows a red radial gradient applied to a plain circle to create a simple 3-D effect.

To create a custom gradient:

  1. On the stage, select the object to which you want to apply a custom gradient.

    Flash highlights the selected object.

  2. Apply a gradient swatch to the object (see Saving Color Swatches).

    If you like, change the color of the gradient, as described next.

  3. In the Color panel, double-click the first color pointer to select it.

    Flash displays a color picker.

  4. In the color picker, click to select a color.

    In your selected object, Flash turns the color at the center (for a radial gradient) or at the very left (for a linear gradient) to the color you chose. Repeat these two steps for each color pointer to change the color of each band of color in your gradient. If you like, change the thickness and definition of your gradient's color bands, as described next.

  5. In the Color panel, drag the first color pointer to the right.

    The farther to the right you drag it, the more of that color appears in your custom gradient. The farther to the left you drag it, the less of that color appears in your custom gradient. Repeat this step for each band of color in your gradient.

    Next, if you like, you can add a new band of color to your custom gradient.

  6. In the Color panel, click anywhere on the Gradient edit bar.

    Flash creates a new color pointer (see Figure 5-48), which you can edit as described in step 3. You can add as many as 15 color pointers (new bands of color) to your gradient.

    For even more excitement, apply one or more gradient transforms to your object, as described next.

  7. In the Tools panel, choose the Gradient Transform tool (F). It shares a fly-out menu with the Free Transform tool.

    Flash displays a rotation arrow, a stretch arrow, and a reposition point.

    You can drag the rotation arrow to rotate the gradient; drag the stretch arrow to stretch the bands of color in your gradient, as shown in Figure 5-49; or drag the reposition point to reposition the center of the gradient, also shown in Figure 5-49.

Depending on the type of animation you're creating in Flash, you might find it easier to import a custom color palette than to try to recreate each color you need. For example, say you're working on a promotional piece for your company, and you want the colors you use in each and every frame of your animation to match the colors your company uses in all its other marketing materials (its brochures, ads, and so on). Rather than eyeball all the other materials or spend time contacting printers and graphics teams to try and track down the RGB values for each color, all you need to do is import a GIF file into Flash that contains all the colors you need: a GIF file showing your company's logo, for example, or some other image containing the colors you need to match.

To import a custom color palette:

Tying color elements together is a subtle—but important—element of good design. It's the same principle as accessorizing: Say you buy a white shirt with purple pinstripes. Add a pink tie, and you're a candidate for the Worst Dressed list. But a purple tie that matches the pinstripes somehow pulls the look together.

In Flash, you may find you've created a sketch and colored it just the right shade of green, and you want to use that color in another part of the same drawing. Sure, you could slog through the Color panel, write down the hexadecimal notation for the color and then recreate the color. Or, if you know you're going to be working a lot with that particular color, you could create a custom color swatch (Saving Color Swatches). But if you want to experiment with placing bits of the color here and there on the fly, the Eyedropper tool is the way to go. The Eyedropper tool lets you click the color on one image and apply it instantly to another color on another image.

To copy color from one object to another:

  1. Select Edit→Deselect All.

    Alternatively, you can press Ctrl+Shift+A (Shift-⌘-A) or click an empty spot on the stage.

  2. From the Tools panel, click to select the Eyedropper tool.

    As you mouse over the stage, your cursor appears as an eyedropper while it's over a blank part of the stage; an eyedropper and a brush when it's over a fill (as shown in Figure 5-52, top); and an eyedropper and a pencil when it's over a stroke.

  3. Click the bitmap, fill, or stroke color you want to copy from (imagine sucking the color up into your eyedropper).

    If you click to copy from a fill or a bitmap, your cursor turns immediately into a paint bucket; if you click to copy from a stroke, the cursor turns into an ink bottle.

  4. Click the bitmap, fill, or stroke you want to copy to (imagine squeezing the color out of your eyedropper). If you copied color from a bitmap or a fill, you need to click a fill; if you copied color from a stroke, you need to click a stroke.

    Flash recolors the stroke, fill, or bitmap you click, applying the from color to the to color, as shown in Figure 5-52, bottom.