Section 5.3. Importing Vectors


5.3. Importing Vectors

As is true with raster graphics, Flash can import vector assets from a variety of external applications, and in a variety of formats. Here, we'll look at how to import Adobe Illustrator, Macromedia FreeHand, and Adobe PDF assets, and even other SWF files.

5.3.1. Importing from Illustrator or FreeHand

Both Illustrator and FreeHand support enhanced importing options, as seen in Figure 5-11. Both will allow you to convert drawing layers to Flash layers or keyframes, as well as flatten the drawing into one layer and keyframe of vectors. They also both allow you to optionally import hidden layers and maintain text blocks. Finally, Illustrator allows you to rasterize the entire drawing into a bitmap of almost any resolution. (You will learn more about pages in the section "Importing from PDF.")

Figure 5-11. Standard vector asset import settings


If you have Illustrator, you can open the tabbed.ai file (found in the /05/Importing Vectors folder) in Illustrator and the companion ai_keyframes_01.fla file in Flash. You will see the beginnings of an interface, as layers are converted to keyframes upon import. In the next step of the process, shown in ai_keyframes_02.fla, simple scripts have been added directly to the buttons to mock up the tabs in action. Although a very simple example, this is an excellent way to get an interface working quickly in Flash if you are comfortable with a particular drawing program.

Special features in drawing programs can also be used to great advantage. For example, FreeHand's Xtra, Animate Release to Layers, can be used to turn shape tweens (called

If you have a recent copy of FreeHand, begin by opening flower_01.fh11, found in the /05/ Importing Vectors folder. Using the aforementioned Xtra, this single-layer file is turned into flower_02.fh11. Each element is repeated on a new layer, adding a new element each time. The result is an animation build that can be immediately translated into Flash.

If you don't have FreeHand, or you want to move on, import the result that has already been prepared for you:

  1. Create a new, blank document and save it as fh_flower.fla in the /05/Importing Vectors folder.

  2. Import the flower_02.fh11 file found in the same folder.

  3. Match your settings to those found in Figure 5-11.

  4. Once the import is finished, save your work and test your movie. The flower animation will build over time.

When you are finished viewing the animation, close the .swf and return to your .fla. Open the Library and notice that six new symbols have been added to the file. These were originally FreeHand symbols, but they have been conveniently converted to Flash symbols for you. With a little advanced planning, FreeHand economies can make your Flash files more efficient, too.

Functions

As discussed briefly in Chapter 4, a function is a set of actions that Flash can perform only when called upon to do so. This is useful for preventing the actions from executing automatically, as would be the case in a simple frame script.

If you've been following along with the projects in this book, you've already been exposed to functions a few times. Although not too much attention was focused on functions themselves, you've seen them used with button and movie clip event handlers, like so:

 start_btn.onRelease = function() {     myClip1.play(); }; 

This type of function is called an anonymous function because it has no name. Instead, it is directly associated with an event handler, and the function is called by the event in question. In the above case, the function is called when the mouse is clicked on the button named start_btn and then released.

Custom functions can also be named and called any time, not just when associated with a specific event handler. For example, the following function will set the location of two movie clips and play them both:

 function playAllClips() {     myClip1._x = 20;     myClip1._y = 20;     myClip1_mc.play();     myClip1._x = 60;     myClip1._y = 20;     myClip3_mc.play(); } 

Once defined, you can then call this function by name from another script:

 playallClips(); 

A few simple rules must be followed when working with functions, but they're easy to understand and remember. You'll learn more about their use when you work with functions in several other chapters, and during the discussion of scope in Chapter 7. You won't need to grapple with all of this nowfor now, it's helpful merely to understand the purpose and structure of a function so you'll know what it is when you see it.


5.3.2. Importing a SWF

In most cases, you can even import a .swf into your .fla file. (In a later chapter, you will learn how to protect your .swf files from importing, but for now, you will work with the default setting where protection is not enabled.)

When importing SWF files, you will not be able to import much more than graphics. However, this is still useful if you want to bring a SWF created by another program into a Flash file that you're working on.

Many third-party programs, including FreeHand and Illustrator, can create .swf files. These export options can even be used to create simple animations without ever opening Flash. Illustrator, in particular, can often provide better results in color and shape translations (especially from a CMYK original) by exporting a .swf that you then import into Flash, rather than importing the Illustrator or .swf document directly.

Exporting a .swf from a third-party tool is usually straightforward. Figure 5-12 shows the Illustrator options, as an example. Note that you can convert layers to keyframes (or files, or create one composite file). You can also apply a small selection of settings for direct export to animation, preserve appearance or editability, and set bitmap compression settings for converting embedded bitmaps.

Figure 5-12. The export features in FreeHand and Illustrator (shown here) allow you to create SWF files directly from within these programs


5.3.3. Importing from PDF

Flash 8 can import PDF documents, using the same vector import dialog discussed previously. Depending on how complex the PDF is, Flash usually does a pretty good job of reproducing the original content.

In basic terms, importing a PDF is no different from importing an Illustrator or FreeHand file. However, the following project will give you a chance to experiment with Flash's Convert Pages to Scenes option. Although pages are supported in other applications, the idea of pages in a PDF is very intuitive and common, so you'll run with that idea now:

  1. Create a new, blank document and save it as pdf_scenes.fla in the /05/Importing Vectors folder.

  2. Change the dimensions to 640 x 480, using the Modify Document menu command.

  3. Import the .pdf into Flash. When the import dialog appears, match your settings to those seen in Figure 5-11, except for the first option. For this project, change the "Convert Pages to" option to Scenes instead of Keyframes.

  4. Save your file and look at the result of the import.

You will probably notice right away that only one page of the PDF is visible. This is because the two pages have been separated into two discrete segments, called scenes.



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

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