- 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: Start Using a Shared Item
In this task you'll create a user file that can access the contents of the Shared Library you created in the previous task. Here are the steps:
Create a new file (Ctrl+N) and select Save As.... Name the file user1.fla and save it in the RuntimeSharing folder (from the previous task). Now you have to get those shared items into the new movie. You could copy instances from the shared.flabut this would involve first creating instances (by dragging from the Library) and then pasting into user.fla. I think an easier way is to open shared.fla as a Library. To do that, make sure you're editing user1.fla and select File, Open as Library and then select shared.fla. You'll see the Library from shared.fla, but notice that it's darkened a bit to represent that it's from another file. You can now use instances from this movie without adding to the file size of the user1.fla file.
Drag items from shared.fla's Library to the Stage of user1.fla. Drag the bitmap onto the Stage. Then open the Library for user1.fla (Ctrl+L) and notice that the bitmap looks like it was copied into the Library. Now, try dragging the sound from the shared.fla's Library to user1's Library. Finally, drag the "box" onto the Stage. File user1.fla now seems to have three items added to its Library (see Figure 19.8). However, these are really just instances pointing to the master version in the file shared.fla.
Go ahead and double-click the "box" clip in your user1.fla movie. You'll see a dialog box like the one shown in Figure 19.9. Click No. The point is that you can only make edits to the master when you open shared.fla. By the way, you can drag instances from user1's Library onto the Stage, and you're still using instances of the masters saved in shared.fla.
Do a Test Movie and then look at the file sizes. The shared.swf file should be rather large (it has a bitmap, sound, and Movie Clip). The user1.swf file should be tiny, because it only points to the shared.swf file. By the way, if you move or change the name of shared.swf, the file user1.swf won't work!
Figure 19.8 After you bring assets from a Shared Library into a user file, they appear to be included in the user file's Library.
Figure 19.9 Trying to edit a clip set up for runtime sharing will cause this dialog box to appear. It basically says that if you want to edit the clip here, it won't be linked any more. Editing the original is done through the source movie.
- While you're inside user1.fla take a look at the linkage settings under each item's linkage properties. You should see "Import for runtime sharing" selected as well as the identifier and URL fields filled in. These settings mean that, when exported, this movie will look in the file shared.swf for items with the identifier listed.
What's the big deal? You have two files, and one's bigger than the other. So what? First of all, you can repeat the last task, but this time you can name the file user2.fla. You can use instances of the same symbols (maybe in different ways), and user2.swf will be tiny, too! Visitors to your site will download shared.swf only once, regardless of whether they view user1.swf or user2.swf, or both. Additionally, you can change the contents of shared.flamaybe change the bitmap or the "box" symbol. Making a change and exporting shared.swf again will enable all your user files (user1.swf, for example) to reflect the change. This is just like how you can change a master symbol and every instance reflects that change. You'll now give it a try. (If you want to first repeat the preceding task, but name your file user2.fla, you may.)