Creating Graphics in Flash MX
In This Chapter
Creating Custom Colors and Gradients
Tips for Creating Graphics in Flash
Importing Bitmap Graphics
Working with Bitmaps
Flash has a unique drawing style associated with it. If you are familiar with other drawing applications, such as Adobe Illustrator and Macromedia FreeHand, you'll find definite similarities and some unexpected differences. Flash offers several drawing tools that allow you to create the graphics for your Flash projects that may seem familiar to you based upon some of those programs. Flash differs from those other applications by the way it handles graphics. Flash will join two items of the same color value if the two graphics intersect. The line or stroke of an item is also considered a separate element. As you will see in this chapter, these differences can be problematic; they can also work in your favor. It's just a matter of getting use to them.
As just mentioned, the drawing and handling of graphics in Flash takes a little getting used to, and that's what this portion of the chapter is for. It exposes you to the tools in Flash MX, and even though they may look very similar to those in other programs, this is a different user experience.
All the tools will be reviewed in this chapter, so let's take a look at what these tools look like. Figure 3.1 shows the Flash MX toolbar and highlights each tool found in this powerful toolset.
Figure 3.1 The Flash MX tools.
The Arrow Tool
The Arrow tool is Flash's selection tool. If you want to move an item, select and drag it with this tool. Of course, you can always use the arrow keys on your keyboard to move the item for more precise placement.
Toward the end of the chapter, once we get into actually creating artwork in Flash, you'll see how this tool can also be an aid in drawing. The Arrow tool does have one option: Snap to Objects.
Use Snap to Objects to have artwork snap to the grid. This option will also cause objects to snap to one another when you're placing the graphics, depending on how close the objects are horizontally and vertically.
The Subselection Tool
The Arrow tool has a counterpartthe Subselection tool (also known as the white arrow). Remember that Flash is vector based, and the main job of the Subselection tool is to select actual vector points of an item. Again, we'll discuss this later in the chapter as we begin creating and working with our own artwork using the Pen tool.
The Line Tool
When drawing with the Line tool, you have the ability to create straight lines in any direction from the starting point. To start drawing a line, choose the Line tool in the Tools panel, click anywhere on the stage, drag the line towards the desired endpoint, and release the mouse. The Line tool has no options. However, the size and style of the stroke will determine the appearance of the line. The stroke's properties can be changed in the Properties Inspector when the Line tool is selected in the Tools panel.
Notice in Figure 3.2 that you can draw several line segments to make a shape.
To change the appearance of the stroke, you can select a color and size from the Properties Inspector. You also have a choice of stylessolid, dashed, dotted, ragged, stipple, and hatchedas well as options to customize each of these styles. Simply click the Custom button in the Properties Inspector with a drawing tool selected. Here's an explanation of each style option:
Figure 3.2 The Line tool can be used to draw a triangle by connecting three different lines. Notice the Properties Inspector's options for changing the line's appearance.
Flash does not offer a way to save custom style settings. Also, all units for spacing and sizing options are in points. You can access the Stroke Style dialog box by clicking the Custom button in the Properties Inspector. Once you click the button, the dialog box will appear, as shown in Figure 3.3.
Figure 3.3 The Stroke Style dialog box.
Hairline. This stroke style draws one-pixel-wide strokes and remains one pixel, regardless of magnification or zoom. Oftentimes, when a document gets scaled, the vector lines will scale with it to preserve the proportions of the artwork. This is not an option in the dialog box but is available through the pop-out menu in the Properties Inspector.
Solid. This option is for drawing solid lines and strokes. The only adjustable attributes are the thickness, color, and sharp corners of the stroke.
Dashed. This choice generates a stroke with dashed breaks within the line. To change the length of the dash and the gap space between dashes, enter in numeric values in the respective text fields. Color, thickness, and sharp corners are also adjustable attributes.
Dotted. Choose the dotted style if the desired effect is to have a stroke with evenly spaced dots along the line. This style has an option for changing the distance between the dots. Color, thickness, and sharp corners are also adjustable attributes.
Ragged. The ragged style creates random wavy lines with dotted separations. The Stroke Styles dialog box offers options to change the pattern, wave height, and wave length. Color, thickness, and sharp corners are also adjustable attributes. Use a combination of all these styles for unlimited possibilities.
Stipple. This choice creates a stroke style to resemble that of an artist's hand-stippling technique. Dot size, dot variation, and density are options for changing the appearance of the stippling effect. Color, thickness, and sharp corners are also adjustable attributes.
Hatched. The hatched line style resembles an artist's hatched-line technique. The Thickness attribute determines the thickness of the hatch line, which is independent of the global thickness setting. You also have options for spacing, jiggle, rotate, curve, and the length of the hatched lines. Of course, there are additional choices for global thickness, color, and sharp corners.
The Ink Bottle Tool
The Ink Bottle tool is designed to change the color, style, and thickness of strokes. If you use the Dropper tool to sample the stroke appearance of any art in Flash, after the sample has been made, the Dropper tool will automatically take on all the characteristics of the sampled stroke. The Ink Bottle does not have any options, but you can choose the color, thickness, and style of the stroke using the Properties Inspector in conjunction with one of the vector drawing tools.
The Dropper Tool
Use the Dropper tool to select color values on the screen. If you are drawing a new object and prefer for the fill or stroke color to appear the same as any other value on the screen, simply use the Dropper tool to sample that color value. Once you click the color value, it's automatically stored in the appropriate Ink Well tool in the Tools panel. If you choose a stroke color, all attributes of that stroke (including size, color, and style) will be sampled. If you are using the Dropper tool from the Tools panel, you are limited to sampling within the confines of the stage. If you are using the Dropper tool built in to the Swatches panel, you can sample a color from any source on the computer screen.
The Pencil Tool
When drawing with the Pencil tool, you'll notice it uses a stroke color opposed to a fill color. You may also change its stroke appearance by choosing a stroke style in the Properties Inspector. The Pencil tool has some interesting options that can aid in the final outcome of a drawing. These options are detailed in the following list and displayed in Figure 3.4:
Figure 3.4 Pencil tool options.
- Straighten. Choose this option if your goal is to draw a perfect circle, oval, square, rectangle, or arc. The sensitivity of how Flash determines a shape is set in the Preferences dialog box. You can access these preferences by choosing Edit, Preferences. For more information on preferences, refer to Chapter 2, "Introducing Flash MX." Check out Figure 3.5 to see an example of drawing with Straighten turned on.
Figure 3.5 A circle before and after the release of the mouse.
Smooth. Generally this option will smooth out any curvy lines.
Ink. This choice is for freehand drawing without Flash making adjustments to the lines.
When you're drawing with the Ink option selected, it may look like some modification is happening to your lines when the mouse is released. Flash isn't making any adjustments to the curviness or straightness of the line; rather, it's antialiasing the edges of the line.
After the line has been drawn, you may feel that it needs to be smoother or straighter. This not only may aid in the visual appearance of the stroke, but you may actually reduce file size by reducing the complexity of the stroke. To make a line straighter, follow these steps:
Click the line with the Arrow tool. The line will be selected.
With the line selected, in the Options portion of the toolbar, as shown in Figure 3.6, choose the Straighten button.
Click the Straighten button as many times as needed to get the desired effect.
The same method will work when smoothing a line.
Figure 3.6 The Arrow tool's options.
The Rectangle Tool
Rectangle tool is used to create squares and rectangles. To create a perfect square, hold down the Shift key to constrain the drawn object's proportions to that of a square. One option the Rectangle tool has involves setting the corner radius to make rounded edges. If you click the Corner Radius button, a dialog box will appear. In the text field, type in a numeric value between 0 and 999 that represents the corner radius.
Drawing and Coloring Rectangle Shapes
Here are the steps to follow to draw and color a rectangle shape:
Choose the Rectangle tool from the Tools panel.
In the Color portion of the Tools panel, choose a stroke color. If no stroke is desired, choose the first box in the top-right corner of the swatches, as shown in Figure 3.7.
If you would prefer to use a custom color, something other than a web safe color, click the button to the right of the No Stroke button to bring up the Color Picker. Inside the Color Picker are many different ways to view color in terms of organization.
Choose a fill color. All the same techniques in terms of color selection used for the stroke apply to the fill as well.
To create rounded edges, click the Round Rectangle Radius button in the Options section of the Tools panel.
Place the cursor in the stage; then click and drag until the rectangle is the desired size. If the goal is to create a perfect square, hold down the Shift key.
Figure 3.7 Choosing the No stroke option.
If you choose View, Snap to Objects when you draw a rectangle, you'll notice you have a perfect square because your cursor will snap to a large circle around your cursor, as shown in Figure 3.8.
The higher the value entered in the Round Rectangle Radius dialog box, the more round the corners become. Avoid very large numbers, especially for smaller rectangles. If you do use a large number, you run the risk of turning your rectangle into a circle.
Figure 3.8 Drawing a square with Snap to Objects selected.
When using the Rectangle tool, you may notice some unusual behavior when it comes to moving objects. This is discussed in detail in the "Tips for Creating Graphics in Flash" section, later in this chapter.
The Oval Tool
The Oval tool is used to create circles and ovals. To create a perfect circle, hold down the Shift key. This will constrain the drawn object's proportions to that of a circle. If Snap to Objects is selected when drawing an oval, the shape will snap to a perfect circle when dragged at a 45-degree angle.
The Oval tool has no options.
The Paint Bucket Tool
The Paint Bucket is used to fill an item with a color or gradient. To choose a color or gradient, click the Ink Well tool of the fill swatch in the Tools panel or in the Properties Inspector.
Once the fill color has been selected, move the Paint Bucket tool over an object and click it to change its fill color to the new fill color.
In the Options area of the Tools panel, notice that the Paint Bucket tool has a Gap Size option as displayed in Figure 3.9.
Figure 3.9 The Paint Bucket options.
Select the first choice, Don't Close Gaps, if there are certain areas in your artwork that shouldn't be filled.
The Close Small, Medium, and Large Gaps options all work in the same way. If you have complex drawings that need to be filled, you may want to choose one of these options. If you have Close Large Gaps selected and it doesn't seem like it's working, either the gap is too large or there are too many gaps in your art.
The last option in the Tools panel is Lock Fill, which allows you to apply a gradient or bitmap fill consistently across multiple items.
Using Lock Fill to Apply a Gradient Across Multiple Objects
Here are the steps to follow to use Lock Fill to apply a gradient across multiple objects:
Draw four squares on the stage and align them using the Align panel. Space them out so that the entire stage is being used, edge to edge.
Choose the Paint Bucket tool in the Tools panel and be sure to choose the rainbow linear gradient in the fill swatch.
Click the Lock Fill button in the Options portion of the Tools panel.
Fill the first square, then the second, third, and fourth. You'll notice that the gradient is being applied as if the four squares are one continuous shape.
To see the different squares, fill each one with a gradient without the Lock Fill option selected.
To apply a gradient across multiple items without using Lock Fill, simply choose all the items by drawing an invisible marquee with the Arrow tool or by Shift-clicking each object. Then click one of the items. You'll notice the gradient has applied color across more than one item. The effect, however, looks a bit different when compared to the Lock Fill effect.
If you want to fill the squares with a bitmap, choose File, Import and search for the image on your computer. Once the image is in Flash, highlight it and choose the Modify, Break Apart menu command. For more information on importing bitmap graphics, see the "Working with the Color Mixer" section, later in this chapter.