Section 2.5. Automate Your Workflow

2.5. Automate Your Workflow

Having to manually repeat common tasks, such as drawing a box, can slow you down. To speed up development, Flash can automate many of your efforts. One simple way for users of all skill levels to automate repetitive tasks is to save steps from the Undo History as Flash macros called commands. To start, you need to understand the History panel.

2.5.1. Making History

The History panel begins as a blank slate and tracks your actions while you are editing your movies. This allows you to undo and redo your actions, step by step. As you'll see, it also allows you to replay single actions and save sequences of actions for later use. To take advantage of these features, you need to make history:

  1. Create a new, blank document with which to experiment. Name it history.fla and save it in your 02 directory.

  2. Choose Window Other Panels History to open the History panel.

  3. Use the Selection tool (V) to select the fill, and then change the fill color to light gray.

  4. Select the stroke by double-clicking on any edge, and change the stroke color to dark gray. Then deselect the stroke.

  5. Double-click in the fill area of the square to select both its fill and stroke. Then move it off-Stage.

Have you noticed the History panel filling up with information? It tracks each task you perform in order, resulting in something like the history list shown in Figure 2-10.

Figure 2-10. The History panel

You've already seen how the Undo command can help you travel back in time, but the History panel allows you to retrace as many steps as you please by stepping through a written list of the tasks you have performed. At any point, you can step backward in the History panel and start again from a previous step, or simply repeat a sequence by choosing the steps to replay. Take a look at how it works:

  1. Drag the history slider, indicated in Figure 2-10, up two steps to the step marked Double Click. The box on the Stage becomes selected again and moves back to its original position. Essentially, you're going back in time.

  2. Click once on the first step (Rectangle) in the history list, then hold down the Shift key and click on the last Move action that appears. (This is probably your last step, or possibly next to last if you deselected.) Shift-clicking highlights the entire sequence, selecting the steps in between.

  3. Click on the Replay button at the bottom of the History panel, as indicated in Figure 2-10, to replay the sequence.

  4. Save your work.

Instantly, the steps selected in the History panel are replayed, creating a box in the same position as the first one you drew.

You now know how to perform a sequence of steps and replay them, but the process of drawing the box needs to be simplified so Flash can replay the sequence faster. In this case, you drew a box and immediately changed its colors. It is easier for Flash to replay the sequence if you choose the colors you want before drawing the box, so it's time to simplify.

2.5.2. Economizing a Sequence

A long list of actions in the History panel, like the one you have now, can be difficult to read, and you need to be able to identify which steps to save as part of the sequence. So, the first step in simplifying the creation of your box is to clean up the History panel:

  1. Delete the two boxes from the Stage.

  2. Open the History panel's Options menu and choose Clear History, as shown in Figure 2-11. Flash warns you that the action cannot be undone. Click Yes to continue.

  3. Save your work.

Figure 2-11. The History panel

Now you can cut the drawing process down to four steps, for an economical sequence that can be saved and quickly replayed by Flash. While you're at it, you can add a step that converts the graphic to a symbol, so Flash will also do that when you replay the sequence.

Perform the following steps exactly as they are listed, without any extra clicks or other actions:

  1. Activate the Rectangle tool, disable Object Drawing mode if it is enabled, and choose light gray and dark gray for the fill and stroke colors, respectively.

  2. Draw a square box on the Stage.

  3. Using the Selection tool, double-click the box to select both its fill and stroke.

  4. Convert the box to a movie clip symbol (using Modify Convert to Symbol or F8) and name it box_mc, being sure to set the Behavior radio button to Movie Clip and the registration point to the center. The list in your History panel should match Figure 2-12, or be very similar. It doesnt have to be exact; the goal is just to avoid having many unneeded steps in your sequence.

    Figure 2-12. The history of a box

Your new, more efficient sequence is easier to read and faster for Flash to execute. Next, you'll see how to save and reuse the sequence.

2.5.3. Commands: Next-Generation Macros

To make a sequence of steps reusable (like the macros common to many other applications), you need to save it as a command, as follows:

  1. Select the first step (Rectangle) in the History panel, and then press the Shift key and select the last step (Convert to Symbol) to highlight all four steps. (You can also click and drag from the top of the list to the bottom to select all the steps simultaneously.)

  2. Click the Save Selected Steps as a Command button in the History panel, as indicated in Figure 2-13. This opens the Save as Command dialog box.

    Figure 2-13. Saving selected steps as a command

  3. In the Command Name field, type Make a Box, and click OK to close the dialog box.

Now you have a command that creates a gray box any time you need it. Try starting over to see if it works:

  1. Create a new Flash document. There's no need to name or save it, as you won't use it again.

  2. Open the Commands menu at the top of the document window, as shown in Figure 2-14. The Commands menu shows your brand-new Make a Box command. Congratulationsyou've permanently added a new command to the Flash interface (you can rename or delete it using Commands Manage Saved Commands).

    Figure 2-14. The Commands menu showing the custom Make a Box command

  3. Choose the Make a Box command from the Commands menu.

  4. Open the Library (Ctrl/Cmd-L). You should see a graphic named Symbol 1, which was created via the Make a Box command. Flash names new symbols using the default naming convention Symbol 1, Symbol 2, and so on, unless you enter custom names.

Each time you execute the command, Flash creates a brand-new box and places it in the same position as the box you drew originally. Why? Because the History panel, in addition to tracking steps, tracks the position of the box as you draw it. Also, each time you run the Make a Box command, Flash converts the box to a symbol for you, eliminating the need to repeat the process manually. This is a great time-saver.

So why doesn't Flash use the name box_mc every time you run the Make a Box command? If Flash named every new symbol box_mc, there would be no way to distinguish among them without renaming each symbol. The default naming convention used by Flash (Symbol 1, Symbol 2, etc.) keeps each symbol identifiable in the meantime.

Just as you saved your own command, you can download and install commands created by others. In Chapter 15, you'll learn more about customizing Flash this way. First, however, you'll concentrate on your first animation.

Flash 8(c) Projects for Learning Animation and Interactivity
Flash 8: Projects for Learning Animation and Interactivity (OReilly Digital Studio)
ISBN: 0596102232
EAN: 2147483647
Year: 2006
Pages: 117

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: