- Designing Your Web Site to Be Modular
- Loading Movies or JPGs
- Task: Use Load Movie
- Determining When a Movie Is Fully Loaded and How to Unload It
- Task: Determine Whether a Movie Is Fully Loaded
- Shared Library Items
- Task: Prepare Items to Share at Runtime
- Task: Start Using a Shared Item
- Task: Update Shared Items in a Library
- Task: Share a Font During Runtime
- Linked Scripts
Task: Share a Font During Runtime
In this task you'll set up a font as a shared item so that it can be used by as many user files as you want. Here are the steps:
In a new file (or your shared.fla source), open the Library window. From the Options menu, select New Font....
You'll see the Font Symbol Properties dialog box, which requires you to specify both a new name for your font and which font you want to copy. Suppose you own a font called Blur that you want to share. You need to find and select Blur from the Font drop-down list and then give it a new name. Any name will work (except a name used already). However, let me suggest that you use the original font name plus "_IMPORTED." This way, when you're in the user file, you can find the font alphabetically, but there will be no question which one is imported. Notice in Figure 19.10 that I've given the Blur font the name Blur_IMPORTED.
Figure 19.10 When creating a new font, you must specify the font and the name you want to give it. Adding "_IMPORTED" to the end of the original name makes it clear which font is the "imported" one.
Now you need to make sure Flash exports the font when you export the movie. So, after you're done making a new font, you should notice the "font" item in your Library. Select it and access its Linkage properties (right-click or select the Options menu). Choose Export for runtime sharing and give it the unique identifier "myBlur" (it just has to be a unique name). Also type shared.swf into the URL field.
Save this movie as shared.fla, export it (Ctrl+Enter), and leave it open. Create a new file and save it as user_of_fonts.fla in the same location as shared.fla.
In the last task we used the Open as Library feature. This time, just expand the Library for shared.fla (it should be in gray) and the Library for the new user_of_fonts.fla (Press Ctrl+L if necessary). Drag the font Blur_IMPORTED (or whatever you named the font) from the shared.fla's Library to your open file's Library. Now, finally, we can use this font. Simply create some text and use the Properties panel to select Blur_IMPORTED from the list of fonts! (See how the name you chose made it easy? Flash also puts an asterisk after any imported font names.)
One last note on this subject: Sharing font items isn't just for file size savings. You can use them like styles in a word processor. For example, you can go back to the shared.fla file and edit the font (just double-click the font item in the Library and choose a different font from the Font Symbol Properties). If you then re-export (to replace) shared.swf, you'll see the new font being used in each user file. Notice that in this case, because you're just editing a symbol (the font) you don't have to worry about the linkage settings. If, on the other hand, you actually replaced an entire Library item, you would need to set the linkage and provide the same unique identifier used earlier.
Unfortunately when you change the shared items (in shared.fla) you won't see the change in the user .fla files (just their .swfs). You can get around this fact (as you'll learn in Hour 22, "Working on Large Projects and in Team Environments") by using a feature called "Always update before publishing"however, this only works with shared symbols (not sounds, bitmaps, and fonts).
Basically, all the upfront work in runtime sharing can be very useful, provided you use the same styles and assets throughout many files. It also means that everyone on the team could be given a copy of the latest version of shared.swf to use on their computers. In the end, when everything's published, the latest version of shared.swf will be used by everyone. All it takes is a little planning.