Recipe 3.1. Setting the Background Color


Problem

You want to set the background color for a Flash movie.

Solution

For static backgrounds, select a background color in the Document Properties dialog box. For background colors that can change, use a symbol instance (Graphic or movie clip) with a rectangular fill.

Discussion

There are two types of solid color backgrounds for Flash documents: static and dynamic. A static background is one in which the background color does not change, and it is the simplest to implement. A dynamic background is one in which the color may change. For example, you may want to build an application in which the user can select a background color. Because the background color can change, it's dynamic in such a case.

Every Flash document has a static background built into it. The default setting for Flash document backgrounds is white (although you can assign a new default color). However, you can select a new static background color from the Document Properties dialog box or from the Property inspector. To access the Document Properties dialog box, you can select Modify Document or you can use the keyboard shortcutCtrl-J on Windows and Command-J on Macintosh. From the Document Properties dialog box, you can select a new background color from the Background color selector. Optionally, you can access the Background color selector from the Property inspector. The Property inspector allows you to adjust document settings when no object is selected on stage.

Whether you are accessing the Background color selector from the Document Properties dialog box or from the Property inspector, it works in the same way. When you click the current swatch, it expands the selector so you can pick from one of the 235 swatches. If none of the swatches is exactly the color you want to use, you can use the color wheel to mix a custom color. You can access the color wheel from the upper-right corner of the Background color selector.

As already noted, sometimes an application requires a dynamic background color. In such a case, Flash has no built-in background features that enable that sort of functionality. However, you can achieve the effect without too much difficulty by using a symbol instance. With Flash, you can build a library of reusable symbols. You can build a symbol that contains rectangular artwork, and you can then place an instance of that symbol on the main timeline at the lowest layer so that it appears beneath everything else on stage. As long as the rectangle has the same dimensions as the stage, it will appear to the user as a background. The advantage of using a symbol instance is that symbol instances enable you to add animation and interactivity. For example, by using a Movie Clip symbol instance, you can make the background loop through an animation in which the color slowly changes over time.

If you want to use a component that allows you to add an interactive, dynamic background with little to no programming necessary, you can use the BasicBackground component from the Flash 8 Cookbook components (downloadable from http://www.rightactionscript/fcb).




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