Section 14.1. Optimizing Flash Documents


14.1. Optimizing Flash Documents

The larger your published Flash animation file size, the longer it takes for your audience to download it off the Web, and the more stress it puts on their computers when it does begin to play. (Find out more about the difference between an editable .fla Flash document and a published, ready-to-roll .swf document on Section 14.2.) A large file size can cause someone to stare at a blank screen for seconds or even minutes at a time, while she waits for your animation to download and begin playing. A large file size can also cause your animation (including any sound files it contains) to play in fits and starts once it does begin.

Figure 14-1. Flash lets you choose how to deliver your compiled animation: as a standalone projector file (a self-contained executable file you double-click to run, with no need for a Web browser or a separate Flash Player), a QuickTime movie, an image file, or embedded in a Web page (shown here).

Optimizing your animation means paring down file size by making various changes to your images, text, and other elementsall while making sure your animation continues to play the way you want it to. You can think of optimization as low-fat cooking for the animation set: The goal is to get rid of the fat without getting rid of the flavor. And, like low-fat cooking, Flash doesn't offer a single approach to optimization; insteadbecause every animation and target audience is differentyou need to experiment, tweak, and retest using the strategies outlined below.

FREQUENTLY ASKED QUESTIONS
The Importance of Being Optimized

In an era where lightning-fast connections, high-speed processors, and multimegabyte memory cards abound, why should I bother optimizing my Flash documents?

Here's why: Not everyone has access to the latest, greatest equipment and Internet service. In many parts of the world, people don't have access to affordable T1 connections, for example. Also, folks relying on the computers at their schools or jobs don't have control over their equipment. And, of course, not everyone has the time, money, or patience necessary to upgrade every time a new "revolution" in hardware or software technology hits the market.

There's a tendency among some animators ( especially those who don't have a background in building non-Flash software programs) to resist the extra effort that optimizing their animations (as you see on Section 14.1.1.5) requires. But here's the fact: If people can't see your animation, nothing else matters. Not the beauty or cleverness of your artwork, nor the sophistication of your animated sequences, nor the appropriateness of your perfectly synchronized background music.

Here's a short list of the most common excuses some animators give for not optimizing their animations (and the reasons why these excuses don't fly):

  • It looks great on my machine. If my audience doesn't have a fast enough connection, they need to upgrade . Animators and others using Flash tend to be running high-end equipmentmuch faster and more powerful than the equipment their audiences are running. That's why testing your animation at a variety of connection speeds (as discussed on Section 13.5.1.1) and even on a variety of machines, if possible, is so important. As noted above, not everyone can upgrade, and not everyone wants to. But even if they do, chances are they're not going to do it just to see your animation.

  • So what if it takes 5 minutes to download my animation file? My animation is so fantastic it's worth waiting for . It doesn't matter if your animation is in line for the next Webby Award: If your audience can't run it (or surfs away impatiently instead of waiting for it to download and stutter across their screens), you haven't communicated effectivelyand communicating effectively is, or should be, the goal of every animation you create in Flash.

  • The big boys (Hollywood trailer- makers , high-end advertisers, and super-sophisticated, high-traffic sites) don't worry about optimization. Why should I? It's true that some folks would still check out the latest Hollywood teaser even if it took all day to download. But they don't have to because the big boys pay an army of professional testers and software designers to optimize their animations using the techniques in this chapter.

The bottom line, as you've read over and over in this book, is to determine the needs of your target audience first and then construct your animation to meet those needs. If you're delivering your animation as a standalone file on DVD, you're absolutely sure that your audience will be running high-end equipment, and you know for a fact they're highly motivated to run your animation (for example, they have to work through the Flash training tutorial you created in order to keep their jobs), then by all means take optimization with a grain of salt. But if your audience fits any other profile, ignore optimization at your own risk.



Tip: As you check out the optimization strategies in this section, keep in mind that effective optimization is always a balancing act. You may decide some effects are worth the bloated file size they require, and some aren't. In still other cases, you'll want to compromise. For example, you might choose to remove half of the gradient effects you've applied to your images so that you reduce file size, but keep the other half. In Flash, you're the director, so you get to decide how much is enough.

14.1.1. Ten Optimization Strategies

Below you'll find 10 different strategies for keeping file size down by tweaking the images you draw, the bitmaps you import, the graphic effects you apply, and more. Apply as many of the strategies as you can. You can use any of these techniques to trim down a completed animation. Better yet, keep them in mind as you create your next animation. That way, you'll end up with a streamlined animation without a lot of extra, after-the-fact work.

14.1.1.1. Choose tweens over frame-by-frame animations

Every time you add a keyframe to your Timeline, the size of your file goes up dramatically. In contrast, when you use a motion or shape tween (Chapter 3), Flash only has to keep track of the beginning and ending keyframes; for the in-between frames it generates, it has to save only a few calculations. (Obviously, there are times you need to use frame-by-frame animation to create the effect you're after; but for those times when tweening will do the job, use it.)

14.1.1.2. Choose the Pencil tool over the Brush tool

Brush tool fills are more complex than the lines you create with the Pencil tool, so brush strokes take up more file space. When you feel both strokes are equally acceptable, choose the Pencil.

14.1.1.3. Choose solid over dashed or dotted lines

Through the Property Inspector, Flash lets you apply a handful of dash-and-dot effects to the lines you draw on Stage using the Pencil, Pen, Line, and Shape tools (Section 2.3.1). But do so sparingly, because these line effects increase file size.

14.1.1.4. Simplify curves

The less points that make up your lined curves and fill outlines, the less information Flash has to keep track ofand the smaller your file size. Flash even gives you a special Optimize command to remove superfluous points from your shapes . Here's how to use it:

  1. Select the curved line or fill outline you want to optimize and then choose Modify Shape Optimize .

    The Optimize Curves dialog box you see in Figure 14-2 (top) appears.

  2. Drag the smoothing slider to tell Flash how much optimization to apply, from none to maximum, and then click OK .

    Flash displays a message (Figure 14-2, bottom) letting you know what percentage of the selected line or outline it was able to dispense with.

  3. Click OK .

    On the Stage, you see the (subtle) results of the optimization.

Figure 14-2. Top: Optimizing a line doesn't straighten it out or even smooth it the way that Modify Shape Straighten and Modify Shape Smooth do; instead, it ever-so-subtly shifts the points that make up the line. If you want to see how successful the optimization is, make sure you leave the Show totals message checkbox turned on.
Bottom: Because optimization is a final tweak meant for you to do after your image already looks the way you want it to look, you dont see a huge reduction in size here. Still, depending on the number of curved lines and fill outlines your animation contains, the saved bytes can add up fast.

14.1.1.5. Use symbols

Creating a reusable symbol (Chapter 7) allows you to add multiple instances of a shape or drawing to your animation without dramatically increasing file size. Even shrinking, rotating, or recoloring your instances costs less in file size than creating separate images.

14.1.1.6. Avoid bitmaps (or optimize them)

Bitmaps are expensive in terms of file size. If you can do without them, do so; if not, crop them (so that you use as little of them as possible) or optimize them by choosing a higher-than-standard compression option, as described below.


Note: You can also optimize bitmaps in the Publish settings (Section 14.2.1).

To optimize a bitmap:

  1. Import the bitmap into your document's Library panel .

    The steps, if you need a refresher, are in Chapter 8 (Section 8.1.1).

    In the Library, double-click the icon next to the imported bitmap's file name . (Or select the bitmap, and then, from the Options menu in the upper-right corner of the Library, choose Properties.)

    Either way, the Bitmap Properties window you see in Figure 14-3 appears.

  2. From the Compression drop-down list, choose either "Photo (JPEG)" or "Lossless (PNG/GIF)."

    Choose the first option if your image contains a lot of different colors or transparent effects; choose the second if it contains a few solid lumps of color . Find out more about JPEGs, PNGs, and GIFs beginning on Section 14.2.

    Flash calculates a percent compression rate and displays it near the bottom of the Bitmap Properties window.

    If you chose "Photo (JPEG)", you can compress the image further. Turn off the "Use imported JPEG data" checkbox and then type a number into the Quality box that appears (Figure 14-3).


    Tip: Flash starts you out with a quality rate of 50. You need to experiment to find out the lowest number that gives you an acceptable tradeoff between file size and quality, but one way to begin is to jot down the current file size (Flash displays it just below the Quality field), type 25 , and then click OK. When you open the Bitmap Properties window again, Flash displays the new file size for the bitmap based on a file quality of 25. If the image looks OK, type a lower number; if not, type a higher number. The higher the number, the larger the file size; the lower the number, the lower the file size.
  3. Take a look at your newly optimized image by clicking the Test button .

    The preview area shows the way the image looks using the optimization settings you chose. Near the bottom of the Bitmap Properties window, you see the percent compression rate Flash has calculated based on the Quality setting you typed in. If the image quality looks horrible, repeat step 2 with a higher quality setting; if the quality looks okay but the compression rate doesn't seem low enough, try again with a lower quality setting. (Sometimes, depending on your image, a lower quality setting will look practically identical to a slightly higher quality setting.)

  4. When you're satisfied with the quality-vs.-file size tradeoff, click OK .

    Flash hides the Bitmap Properties window and returns you to your workspace.


Note: The image doesn't appear optimized in the Library preview area, and when you drag an instance of the bitmap symbol to the Stage, the image doesn't appear optimized there, either. To see the effects of your optimization settings on the Stage, select Control Test Movie.

14.1.1.7. Keep sound clips to a minimum; when you do use them, optimize them.

Sound clips can quickly swell your animation size. Always use the shortest clips you can get by with (Section 8.2.3 shows you how to shorten sound clips) and optimize them by compressing them as much as possible without sacrificing too much sound quality.

To optimize a sound file:

  1. Import the sound file into your document's Library panel .

    Section 8.2.1 has the full detail on importing audio files.

  2. In the Library, double-click the icon next to the imported sound file's name .

    Alternatively, select the sound file, and then, from the Options menu in the upper-right corner of the Library, choose Properties.

    Either way, the Sound Properties window you see in Figure 14-4 appears.

  3. From the Compression drop-down list, choose a compression scheme .

    Section 14.2.2 describes the different schemes.

  4. When you're satisfied with the quality-vs.-file size tradeoff, click OK .

    Flash hides the Sound Properties window and returns you to your workspace.


Note: To make sure Flash uses the compression option you set in the Sound Properties window, turn off the "Override sound settings" checkbox in the Publish Settings dialog box. Section 14.2.2 has details.
14.1.1.8. Group elements

Grouping shapes, lines, and other portions of your drawings (by selecting them and then choosing Modify Group) cuts down on file size because Flash can streamline in the information it needs to store. Chapter 5 (Section 5.1) has full instructions.

Figure 14-4. If you leave Compression set to Default, Flash uses the compression option you set in the Publish Settings window (Section 14.1) to figure out how to compress this sound clip. Otherwise, Flash applies the Compression option you set here (unless you've told Flash to override this compression setting; see Section 14.2.2 for details).

14.1.1.9. Avoid the extraneous

The more you add to your animation, the larger your file size. If you absolutely, positively need to pare down your file, consider removing or simplifying some (or all) of your drawings, multimedia files, and graphic effects, paying particular attention to these space hogs:

  • Sound files, embedded video clips, and bitmaps

  • Gradient effects

  • Alpha (transparency) effects

  • Custom colors


Tip: If you can't bring yourself to do without media files altogether, go ahead and use thembut abbreviate them. For example, instead of using a long sound clip, loop a short one. Or use a single sound clip a bunch of different ways (soft, loud, the first half, the second half) to create multiple sound effects for minimal overhead. Instead of embedding a video clip as is, try adjusting the in and out points to clip off any nonessential intro or outro frames when you import it into Flash (Section 8.3). And if you're using a mask layer (Section 6.1.8), make sure you clip off every scrap of the background image not revealed by the mask.
14.1.1.10. Tell Flash to keep your file size down

One of the options you want to make sure you set when you're ready to publish your animation is the "Compress movie" option in the Publish Settings dialog box (Section 14.1). (Out of the box, Flash turns on this option, but do double-check that you haven't inadvertently turned it off.) Choosing this option tells Flash to squeeze your animation file as much as it can without sacrificing content. How much Flash compresses your file depends on the specific elements and effects you've included in your animation; the more text and ActionScript code your animation contains, for example, the more "bloat" Flash can squeeze out of your file.

POWER USERS' CLINIC
Preloading

If you drop in on Flash user groups, you may hear talk of preloading , which is a strategy related to optimization. Preloading means that you use a frame-based script (Chapter 10) to download as much of your animation as you can before you actually need it. For example, to keep your audience entertainedin other words, to keep them from getting so bored waiting for your animation to download that they surf away in frustrationyou might want to display a quick-to-download scene and loop it a few times while your real, byte- intensive animation quietly downloads in the background.

The ActionScript required to create your own preloader script is beyond the scope of this book, but Flash Help has details. Simply choose Help Flash Help and search for "about loading and working with external media." (See the Appendix for more tips on using Flash Help.)





Flash 8
Flash Fox and Bono Bear (Chimps) (Chimps Series)
ISBN: 1901737438
EAN: 2147483647
Year: 2006
Pages: 126
Authors: Tessa Moore

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net