1 February 2009
Basic working knowledge of the Flash interface, use of symbols, and basic Timeline animation. No ActionScript knowledge is required; the code samples included in the article can be pasted into your file, and the sample files include the completed FLA files. If you are already familiar with the basic functions of the Deco tool, you may want to skip the first section on its basic use.
Beginning
Two new decorative drawing tools in Adobe Flash CS4 Professional use the procedural modeling engine built into Creative Suite 4 to draw shapes. This article discusses the Deco tool and Spray Brush tool, and showcases some interesting examples of each.
The procedural modeling engine is a library in Flash that processes algorithms using the Flash JavaScript API (JSAPI). The algorithms are built into structured files that the engine can interpret.
Basic working knowledge of the Flash interface, use of symbols, and basic Timeline animation. No ActionScript knowledge is required; the code samples included in the article can be pasted into your file, and the sample files include the completed FLA files. If you are already familiar with the basic functions of the Deco tool, you may want to skip the first section on its basic use.
The Deco tool and Spray Brush can be accessed from the standard Tools panel in Flash. The basic workflow for any of these new tools is to select the tool from the toolbar, and then click the Stage to start drawing the pattern. Additionally, with a few changes to the options, you can create custom patterns very quickly.
The Deco tool contains three effects: Vine Fill, Grid Fill, and Symmetry Brush. Together with the Spray Brush, they make up the four new tools that were created to use the procedural engine for CS4. Since they all use the same engine, they have similar capabilities and UI, which appears in the vertical Property inspector when each tool is selected.
As the tool and effect are changed, the Property inspector changes to reflect the available options for that effect. They each share some similar UI: the Edit symbol button for replacing the default symbol with a library symbol, a color picker for changing the color of the default shape(s), and a check box for resetting the default shape. Below these common options are the advanced options, which I will discuss in detail in the next section.
To use the Spray Brush, select it from the toolbar: click and hold the regular Brush tool until the brush selection menu pops up, and then click the Spray Brush. Draw on the Stage as you would with the regular Brush, and a spray of small circular particles appears as a Group. Next, try changing the color of the brush by clicking the color picker on the Property inspector and selecting a new color, and then drawing some more on the Stage (see Figure 1).

When the Deco tool is selected, the Effects drop down allows you to select between the three effects: Vine Fill, Grid Fill, and Symmetry Brush (see Figure 2).

To use the Grid Fill, select the Deco tool and then select the Grid Fill effect in the Property inspector. Click the color picker to select a color for the grid, and then click anywhere on the Stage. A grid is drawn with the default settings (see Figure 3).

The use the Symmetry Brush, select the Deco tool, and then select the Symmetry Brush effect from the pop-up in the Property inspector. A set of handles will appear on the Stage at an angle. These handles let you add more shapes to the symmetry or rotate the entire group.
With the Symmetry Brush effect selected, click the color picker and select a color for the symmetry. Next, click anywhere on the Stage (not on the symmetry handles) and a default shape will be added to the symmetry. Next, drag the shorter of the two handles by clicking and dragging the small circle at the end of the handle. Dragging the handles back and forth will add and subtract the shapes from the symmetry. Next, drag the longer handle in the same way to see the entire symmetry rotate (see Figure 4). You can continue adding new shapes into the symmetry by clicking the Stage.
Once you select another tool, the symmetry will be converted to a Group of shapes, and it can not be edited again using the symmetry handles.

To use the Vine Fill, select the Deco tool and then select the Vine Fill effect from the pop-up menu in the Property inspector. Click the color pickers to select a color for the Leaf and Flower, and then click anywhere on the Stage. A vine pattern fills the area you click until it reaches the boundary (see Figure 5). Clicking a shape on Stage will fill just that shape with a vine pattern.

The greatest feature of these new tools is the ability to swap a custom symbol from the library for the default shape that each tool draws. The advanced options for each tool let you define further how each pattern is drawn. Following is an example for a few of the new tools using custom symbols and the advanced options to complete a task quickly that would otherwise take more time to design or use of lengthy ActionScript code.
The Spray Brush is a tool that is common to many drawing tools, so many users will be familiar with its common uses. One interesting difference with the Flash Spray Brush is that since you can substitute a movie clip with an animation inside for the default shape, you can create animated spray patterns in addition to static ones. In this example I'll show you how to create some random bubbles that float upwards (see Figure 6).
First, to create the animated bubble movie clip:
// randomize bubble animation:
// go to a random frame between 1 and 80
gotoAndPlay(Math.round(Math.random()*80));
Next, to use the animated bubble clip as the custom spray brush:
You should see a bunch of bubbles floating up and randomly replacing themselves on Stage. You could enhance the effect by changing the Alpha setting on the bubble shapes to appear more transparent.
The Grid Fill effect can be used for a number of interesting tiling tasks. In this example you'll create a 3D tiled background that might be used in a UI or video game.
First, to create the movie clip to use as the custom symbol for the fill:
var rotationNumber:Number = 0;
tile_mc.addEventListener(MouseEvent.MOUSE_OVER, startFlip);
function startFlip(evt:MouseEvent){
tile_mc.addEventListener(Event.ENTER_FRAME, flipIt);
}
function flipIt(evt:Event):void{
if(rotationNumber < 10){
tile_mc.rotationY += 18;
rotationNumber++;
} else {
tile_mc.removeEventListener(Event.ENTER_FRAME, flipIt);
rotationNumber = 0;
}
}
This code snippet creates a counter called rotationNumber and then uses the counter to flip the tile_mc 180 degrees when the mouse moves over it.
Now, to use the Tile movie clip as the fill for the Grid Fill effect:
As you mouse over the tiled background, you should see the tiles flipping in 3D. You can modify the ActionScript snippet in the Tile movie clip to have the tile flip in a different direction, or at a different speed.
It's possible that you could achieve the exact same effect with even fewer lines of code by creating the 3D rotation as a tween on Stage instead of in ActionScript. Then the only code you would need is to listen for the mouseover event and tell the Timeline to play.
The Symmetry Brush has a variety of translations in the Advanced Options pop-up menu, which make it useful for many tasks. One common task is creating a clock face with 12 hands. Ordinarily this would involve manually drawing the hands on Stage and using the Align panel, or using code with some trigonometry to lay out the hands around a center point. With the Symmetry Brush it is easy to create a custom clock face in just a few steps.
First, to create the movie clip to use as the custom clock hands:

Next, to use the clock hand movie clip as the custom symbol for the Symmetry Brush:



Although these designs aren't anything you couldn't do in Flash before, the significant advantage to using the Deco tool is the speed with which you can draw these types of patterns. Without having to align lots of symbols or snapping to grids, you can use the Deco tool can draw out complex patterns very quickly.
When the decorative effects and custom symbols are combined with the other drawing features in Flash CS4, you can quickly create some interesting effects that would otherwise take a long time to create manually or with ActionScript. Here are a few examples of some effects created in less than five minutes using the Deco tool effects with other features like inverse kinematics (IK), filters, and 3D. The completed sample file is included for each example.
In these examples (see Figures 24 and 25), a small, animated particle has been sprayed on the Stage and then modified with 3D or filters to look "spacey."
In this example, some rectangular patterns have been given a simple animation and then used as the custom symbol for the Symmetry Brush effect. Afterwards, some filters were applied make the overall pattern glow (see Figure 26).
The procedural modeling engine in Flash CS4 Professional was created to accept XML and JavaScript as the description for each Deco tool effect, as well as the Spray Brush. The files are loaded into Flash from an external directory to allow for future extensibility. If you are curious about the scripts that make up the models for the Deco effects, you can see the files that are included with CS4 in the install directory:
C:\Program Files\Adobe\Adobe Flash CS4\en\First Run\ProcScripts
The procedural modeling engine is also coded to search for scripts in the user directory for Flash in a UserScripts folder:
\\UserDir\Local Settings\Application Data\Adobe\Flash 10\en\Configuration\ProcScripts\UserScripts
The folder is not created by default, but if it exists with Deco models in it, they will automatically be loaded into the Effects pop-up menu in the Property inspector of the Deco tool. By copying one of the included scripts into a newly created UserScripts directory and renaming it, you can see how the new item will appear in the Deco tool Property inspector.
Read Drawing patterns with the Decorative drawing tools in the Flash documentation to find out more about the drawing tools. For more advanced information, read Creating animation in ActionScript 3.0 to learn how to programmatically create motion effects to move, resize, transition, and fade movie clips easily in your Flash projects.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
| 04/23/2012 | Auto-Save and Auto-Recovery |
|---|---|
| 04/23/2012 | Open hyperlinks in new window/tab/pop-up ? |
| 04/21/2012 | PNG transparencies glitched |
| 04/01/2010 | Workaround for JSFL shape selection bug? |
| 02/13/2012 | Randomize an array |
|---|---|
| 02/11/2012 | How to create a Facebook fan page with Flash |
| 02/08/2012 | Digital Clock |
| 01/18/2012 | Recording webcam video & audio in a flv file on local drive |