The Concept of the Library

 < Day Day Up > 

The process of using the Library involves creating symbols and then using instances of those symbols throughout a movie. You always have one master version of a symbol stored in the Library. You can drag multiple instances of that symbol from the Library to any other part of the movie even inside other symbols. This might seem like a meaningless procedure, but it has two valuable benefits. First, it means that file size remains small because only the master symbol adds to the file size, and each instance just points to the master (similarly to how a shortcut in Windows or an alias on the Macintosh points to a master file). Second, you can make a visual change to the master symbol, and that change is then reflected in each instance. This is similar to using styles in a word processing document: You make a change to the style, and each instance where you use that style reflects the change. You'll learn more about these benefits in a minute, but let's first go over the basics of how to create and use symbols.

How to Create and Use Symbols

You can use two methods to create symbols: You can either convert any selected object onstage to a symbol or make a symbol from scratch. The following task looks at the first of these methods.

Try It Yourself: Create a Symbol by Converting Selected Objects

In this task you'll create symbols the way I prefer to by using the Convert to Symbol feature. Follow these steps:

1.

In a new file, use the Oval tool to draw a circle. Select the Selection tool and make sure the circle is entirely selected (you can double-click the center, marquee the whole thing, or do a Select All).

2.

Select Modify, Convert to Symbol or press F8. Flash forces you to specify the name and default behavior for this symbol (as shown in Figure 4.1).

Figure 4.1. When you convert to a symbol, you must specify a name and behavior.


3.

You should always name symbols logically. The default Symbol 1 might seem logical, but having 35 symbols all named in this manner can become unwieldy. (You'll learn more about naming symbols later in this hour, in the section "Managing the Library by Using Names, Sorting, and Folders.") Name this one Circle. We'll look at all three types of default behavior eventually, but for now just consider Movie Clip the best choice when you're not sure which behavior is best. Button is useful only when you're creating buttons, and Graphic is primarily used for synchronization applications such as lip-synching. Leave Behavior set to the default, Movie Clip, and click OK. By the way, it's possible that your Convert to Symbol dialog box is set to Advanced so that it looks much larger than the one in Figure 4.1. If this is the case, you can collapse it by clicking the Basic button (which toggles to read Advanced) because we won't be exploring the Advanced settings now.

4.

Open your Library window by selecting Window, Library (or Ctrl+L), and you should notice one symbol, Circle, in the Library. When you selected Convert to Symbol, you did two things in one move: You moved the selected shape into the contents of a Library symbol and you caused the object that remained on the Stage to become an instance of the symbol. If you drag more instances from the Library window (by single-clicking and dragging the picture of the circle from the Library window onto the Stage), all those instances will be equivalent to the instance already on the Stage. (If you double-click by accident, you see Scene 1: Circle in your edit bar, indicating that you're editing the master version of the symbol. In this case, you can simply click Scene 1 to get back to the main Stage.)

5.

After you've dragged a few instances of the Circle symbol onto the Stage, it might look like you have several copies of the master, but actually you have multiple instances of the master. You're about to make a change to the master version (in the Library), and you'll see that change in each instance on the Stage.

Figure 4.2. The Library's options menu includes several choices, including Edit.


6.

From the Library window, double-click picture of your Circle symbol (or select Edit from the Library's menu). It might appear that nothing has happened, but now you're inside the Circle symbol where you can edit its contents. The best indication is the edit bar, covered first in Hour 1, "Basics" (see Figure 4.3). In addition, you should see only one copy of your circle (the original) in the center of the Stage, which appears to have no borders. These clues tell you that you are currently inside the master version of the Circle symbol, about to edit it.

Figure 4.3. You know you're editing the contents of a symbol when you look at the edit bar.


7.

Now get out of the master version and reenter another way. Click Scene 1 from the edit bar, and you return to the main scene (with multiple instances of the Circle symbol). Enter the master version of the symbol by double-clicking an instance of it. You should see the edit bar change (which is always your best clue) and all the other instances dim slightly. This is similar to how you can edit the contents of a grouped shape. In this case, you're doing what's called Edit in Place. In any case, here is where you can edit the Circle symbol.

8.

Take a "bite" out of the master graphic of the circle by using the marquee technique with the Selection tool (see Figure 4.4). If the Circle is a Drawing Object then be sure to double-click it first. This is a drastic edit not something subtle, such as changing the color.

Figure 4.4. The edits you make to this symbol will affect each instance.


9.

Go back to the main scene by clicking Scene 1 in the edit bar. Now all the instances of the Circle symbol have the same bite taken out of them! Any new instances of the symbol that you drag from the Library will have the same effect.

In the preceding task, you converted a selection into a symbol. This left behind, on the Stage, an instance of the symbol you created. The other way to create a symbol is to simply decide that you want a new symbol and create it, as described in the following task. Neither method is better than the other, and both give you the same result.

Try It Yourself: Create a New Symbol from Scratch

In this task you'll make a symbol by using the New Symbol feature. Follow these steps:

1.

In the file that contains the Circle symbol (or a new file), make sure nothing is selected and choose Insert, New Symbol.

2.

You see nearly the same Symbol Properties dialog box that you see when you use Convert to Symbol. In this case, name the new symbol Square and set the Behavior option to Movie Clip. This time when you click OK, you are taken inside the master version of the Square symbol (which is yet to be drawn), as shown in Figure 4.5. You should see the edit bar change accordingly. Think of it this way: Convert to Symbol puts your selection in the Library (end of story), whereas New Symbol makes you name the symbol and then takes you to the master version of that symbol so you can draw something effectively saying, "Okay, you want a new symbol? Draw it."

Figure 4.5. Selecting New Symbol takes you into a blank symbol so that you can draw its contents.


3.

Now that you're in the master version of the Square symbol, you can draw the square. You'll probably want to draw it near the registration point of the symbol, indicated by the plus sign (shown in Figure 4.5). This becomes the reference point whenever you view or change the instance's location onscreen. But how do you get the square you draw in the center? Surely by now you've discovered the Paste in Place command from the Edit menu (or Ctrl+Shift+V). It lets you paste anything in the same location from which you copied it. Interesting, the standard Paste (Ctrl+V) command is really called Paste in Center which turns out to be useful here. Just select your drawn square, cut, and then immediately paste. Presto! It's centered. By habit, I quite often cut and paste everything inside my master Library symbols to get just this centering effect. (By the way, you could also use the Info panel to set the shape's transformation point to 0,0 or use the Align Panel's "To stage" option and then click both Align Horizontal Center and Align Vertical Center.)

4.

When you're done creating the Square symbol, go back to the main scene by either clicking Scene 1 in the edit bar or selecting Edit Scene, Scene 1. Where's the square? Well, New Symbol just creates a symbol and keeps it safe in the Library. Drag a couple instances out on the Stage by opening the Library and then dragging as many instances of the Square symbol onto the Stage as you like.

How Symbols Help You

You might already be thinking of some ways symbols can help you, but likely there are many more you haven't even imagined. Let's go over the two fundamental advantages of storing symbols in the Library: reducing the movie's file size and minimizing your work.

Reducing File Size

Believe it or not, if you have 1 graphic in a Library symbol and 100 instances of that symbol on the Stage, your file is no larger than if you have only 1 instance. Here's how it works: The graphic, movie clip, or button in the master symbol contributes to the file size. Therefore, if the graphic is 1KB, the master symbol adds 1KB; if the master symbol is 100KB, it adds 100KB. The size depends on what's in that symbol. No matter how many times a symbol is used, however, it's only stored once. Even as you drag many instances onto the Stage, the symbol is still stored only once. A tiny bit of data is saved inside Flash that specifies how each instance is different from the others (for example, their positions), so I suppose I lied because each instance does actually add to the file size. However, it's just such a tiny bit of information that it's almost not worth mentioning (but I hate to lie). Imagine what would happen if it didn't work this way; a 100KB graphic used 10 times would make a movie balloon to 1MB! In reality, though, 10 instances of a 100KB symbol might make your file grow to, say, 101K (if even that much).

Symbols might seem great when you need several instances of the same shape. However, using symbols is also powerful because each instance can appear very differently from the others. So far, you've used symbols to display identical replicas of an original. The only way each instance has varied has been in its onscreen position. However, the tiny bit of extra data telling Flash where each instance is positioned onscreen can also contain how each instance is scaled or rotated differently. This way, each instance can look different. You'll learn more about this later in the hour, but for now, you should realize if you have three instances on the Stage and you have each one scaled to a different size, you haven't added to the file size in any significant way.

Minimizing Work

In addition to reducing file size, the Library can reduce the amount of work you do. For example, say you have a block of text (maybe a title) that's used in several places within a movie. If you first put the text in a symbol in the Library, each time you need that text onscreen, you can drag an instance from the Library. Later, if you want to change the text, you can edit the master version in the Library and see the change in every instance. This advantage requires only that you invest a little bit of time and planning.

     < Day Day Up > 


    Sams Teach Yourself Macromedia Flash 8 in 24 Hours
    Sams Teach Yourself Macromedia Flash 8 in 24 Hours
    ISBN: 0672327546
    EAN: 2147483647
    Year: 2006
    Pages: 235

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