Recipe 1.28. Applying a Fill Across Multiple Elements


Problem

You want multiple elements on the stage to share a single gradient or bitmap fill.

Solution

Toggle the Paint Bucket or Brush tool Lock Fill modifier on while filling (Paint Bucket tool) or creating (Brush tool) multiple shapes.

Discussion

By default, each shape that contains a fill has its own fill. For fill styles such as gradients and bitmaps, this means that each shape has its own gradient or its own bitmap.

You might, however, want to make a given fill, such as a gradient or bitmap fill, span from one side of the stage to the other, appearing in multiple shapes. You can cause Flash to share a fill across multiple elements in different ways. If you have already drawn a series of shapes or closed lines and you want to fill them with a shared fill, the easiest approach is to set a gradient or bitmap as the active fill, Shift-select or drag-select all of the elements, and click in any one of them with the Paint Bucket tool. This procedure fills the elements with the same locked fill, regardless of the toggle state of the Lock Fill modifier. Using this method, the fill spans from the left edge of the left-most element to the right edge of the right-most element.

Alternatively, after the elements are drawn, you can click each one individually with the Paint Bucket tool and the Options tray's Lock Fill modifier toggled on. This approach also applies a shared fill across the elements, but it sometimes has an unexpected result. It creates a fill that spans from the left side to the right side of the workspace (which is several hundred pixels wider than the stage). Consequently, the elements display only the portion of the fill that the stage represents. For example, a simple gradient fill from white to black would show only from light gray to dark gray; pure white and pure black values would be offstage.

You can lock fills when drawing with the Brush tool as well, because it creates shapes rather than lines. When using the Brush tool, if a gradient is active, and the Lock Fill modifier in the Options tray is toggled on before you paint the first brush stroke, and you start brushing on an empty stage, Flash draws only the portion of the gradient that overlaps the stage.

In both casesthe Paint Bucket or the Brushthe trick is to define the size of the fill first, then toggle the Lock Fill modifier on and continue creating shapes. Here's how:

  • If you are using the Brush tool, toggle the Lock Fill modifier off, and brush a stroke that is as wide as you want the shared fill to be. (This stroke can be temporary and even drawn offstage.) Then toggle the Lock Fill modifier on, and begin brushing the desired strokes.

  • If you are using the Paint Bucket tool, fill a shape (such as a rectangle) that is as wide as you want the fill to be with the desired gradient. Then toggle Lock Fill on, and use the Paint Bucket tool to fill in remaining elements. Afterward, you can remove the initial shape that you used to define the size of the fill.

It takes some practice to obtain the results that you desire when sharing fills. Just remember to define the size of the fill first, and then start applying it. You can create the appearance of several objects revealing a background by having them share a gradient or bitmap fill.

See Also

Recipe 6.2, Recipe 6.8




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