- 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: Prepare Items to Share at Runtime
In this task you'll create a Library containing items that can be shared. Follow these steps:
Create a new file and immediately save it as shared.fla in a folder called RuntimeSharing. Import one bitmapped image (.jpg, .bmp, or .pct, for example). Delete the bitmap onstage (don't worry, it's still safe in the Library). Also, import one sound file. Finally, create a rectangle and convert it to a symbol (press F8). Then make it a Movie Clip, name it "box," and click OK.
You should now have a Library with three items. Rename each item to "image," "sound," and "symbol," respectively. Generally, the next step is to simply export a .swf containing these three Library items. However, normally when you export a .swf, all unused Library items are excluded; therefore, they don't contribute to the file size. Normally, this is a good thing. The problem is that this time you want all the items in the Library to export with the file! Sure, this will add to file size, but you want these assets to be available to many user files. To ensure that each item is included in the .swf export process, you'll define the linkage properties for each item.
To define the linkage for the sound you imported, find it in the Library, select it and then select Linkage... from the options menu (or right-click). Select the check box next to "Export for runtime sharing." This will expose two other required fields: Identifier and URL. We'll discuss the identifiers later, but generally I recommend trying to use the item's name for an identifier when you can (as you'll see by default) or something generic like "music". Into the URL field type shared.swf because that's the name for this movie once exported. Figure 19.7 shows the linkage settings you should use.
Figure 19.7 Library items' linkage is set to Export for runtime sharing. This way the item will definitely export even if it's not being used in this file.
Go ahead and define the linkage for the bitmap and box movie clip the same way (click Export for runtime sharing and type shared.swf into the URL field).
Now, save (Ctrl+S) and then export this file. You can just do a "Test Movie" (Ctrl+Enter) because it's already saved in the right folder.
Your source items are now ready to be shared. You can think of this as your Shared Library.
Now you can use the shared items in any other movie. Inside the other movies, the items simply need to be set to "Import for runtime sharing." In the following task, you'll start using the items from the Shared Library, and then it should start to make sense.