Recipe 2.6. Exporting Single-Frame Images


Problem

You want to use Flash to export a single frame in a popular image format, such as GIF, JPEG, or PNG.

Solution

Select the frame for which you want to export the contents and then choose to export as image.

Alternatively, change the publish settings to export the format you want and publish.

Discussion

Although you may typically think of Flash as being a tool strictly for exporting SWF content, you can also use it to export a variety of other formats, including single-frame formats such as JPEG, PNG, GIF, BMP, AI, EPS, and more. This trick can be convenient for many possible reasons. For example, you may want to export a still image of a frame or frames from your Flash movie to use for presentation or packaging purposes. And even for advanced Flash developers, the feature can be quite useful, such as to export icons that represent components that they are developing.

There are several ways you can export single-frame content from Flash. These ways can sometimes be used interchangeably, but in other cases you will want to opt for one method over another. One way is to export the content through the File menu by choosing File Export Export Image. Well call this first technique the export image technique. The second is to change the publish settings so that Flash will know to export the image types that you want, and then to use the publish feature to tell Flash to export the file or files. We'll call this second technique the publish settings technique. Let's take a look at each of these two techniques in more depth, including when and why you would want to use one over the other.

The export image technique in Flash is most useful in the following scenarios:

  • You want to quickly export an image file for the current frame without having to go through the extra step of changing the publish settings. If you know that you want to export the image multiple times, consider using the publish settings technique instead.

  • You want to export an image file for a frame in a symbol. When this is the case, you have to use the export image technique. The publish settings technique does not allow you to export images for frames other than frames of the main timeline.

  • You want to export a single-frame format other than GIF, JPEG, or PNG. For example, if you want to export an EPS or AI file, you must use the export image technique. The publish settings technique allows you to export in GIF, JPEG, and/or PNG only when exporting to a single-frame format.

  • You want to publish several single-frame images from your file. The publish settings technique allows you to export only a single image corresponding to a single frame. If you want to export two or more images from the document, you'll need to export them one at a time with the export image technique.

  • You want Flash to automatically crop the image to fit the artwork. For example, if your Flash document is 550 x 400 and your artwork is a 50 x 25 rectangle in the center, you may want the image that you export to be 50 x 25 rather than 550 x 400. The export image technique automatically crops the exported image to the actual artwork on the stage at that frame. Changing the dimensions of the image you export also changes the resolution (thus scaling the image), so there is no way to have Flash not crop the image with the export image technique. The publish settings technique, on the other hand, will default to the document's dimensions. Though you can change the dimensions in the publish settings technique, it will scale the content, not crop it.

To export an image with the export image technique, first move the playhead to the frame for which you want to export the artwork. Then choose File Export Export Image from the Flash application menu system. The Export Image dialog box appears, prompting you to choose the location, name, and format to which you want to export the current frame. Clicking Save after selecting a location, name, and format will either export the file or bring up the Export Options dialog box if the selected format requires that you choose values. The options vary depending on the format, but in each case the options with which you are presented are fairly straight-forward. They involve things such as dimensions, resolution, color depth, and so on.

The publish settings technique offers advantages if you are going to export more than one format or if you are likely to export the image or images more than once. In that case, it is worth changing the Publish Settings options to export the specified format or formats, so that you can export the file or files by pressing keys on the keyboard (Shift-F12) rather than having to navigate menus, specify files and locations, and choose from options each time. You can open the publish settings by navigating to File Publish Settings. With the Format tab selected in the Publish Settings dialog box, check each checkbox next to the formats you want to export. For each selected format, a new tab allows you to adjust the settings for that particular format. For example, if you check the JPEG and PNG format options, a JPEG and PNG tab appears within the Publish Settings dialog box. You can then choose the various tabs to adjust the settings for the corresponding formats. Those settings determine how the files will export.

By default, the files that export when you use the publish settings will be exported to the same directory as the .fla file and with names that correspond to the name of the FLA. For example, if the FLA is named circle.fla, the exported PNG would be named circle.png. You can modify the names and locations to which the files are exported from the Formats tab.

After you've configured the publish settings and you are ready to publish (export) the files, all you need to do is to make sure the correct frame is selected in the timeline and then press Shift-F12 and the files will be exported.

There is a TechNote at http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=4ca37de4&pss=rss_flash_4ca37de4 regarding the keyboard shortcut for publish under Mac OS X.


Take note, however, that when you publish the image or images using the publish settings technique, Flash exports the first frame of the main timeline by default. Remember that you can export only images corresponding to frames of the main timeline using the publish settings technique. However, you can tell Flash to export a frame other than the first frame. The technique varies depending on the image format. For PNG and GIF images, you add a frame label of #Static to the frame for which you want to export the image: select the frame in the timeline, open the Property inspector, and enter the value #Static in the Frame Label field. Then, when you publish, Flash exports the image so that it corresponds to the #Static frame. If you have selected more than one single-frame image format to export, all will correspond to that same frame. For JPEG content, however, the #Static frame label will have no effect. Instead, you must select the correct frame in the main timeline before publishing.




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