< Day Day Up > |
The whole lidea of storing items in your Library is that they're only stored once, regardless of how many times they're used in a movie. However, an item in one movie's Library isn't automatically recycled if you copy it into another movie. Flash has two (confusingly similar) features to let you share Library items among your movies. There are two ways to do it: runtime sharing and authortime sharing. Runtime sharing involves storing Library items in a single source movie (that gets exported as a .swf). Then, one or more user movies can access the source .swf's items. This way, if the source .swf ever gets updated, the changes will be reflected in all user files. This is just like making an edit to a master symbol, except in this case, multiple movies will reflect the change instead of just multiple instances within one movie. Authortime sharing is slightly less complex than runtime sharing. You still have one source movie containing Library items. But with authortime sharing, the shared items get recopied into each user file every time you use Test Movie. That is, the user files copy the shared Library item at the time of export. So if a change occurs in the source item, all user files have to be reopened and exported to reflect the change. Plus, each copy of the source adds to the file size of the user files. It's true that authortime sharing is not as modular as runtime sharing, but it's appropriate for larger common elements that you want copied into each user file. One limit of runtime sharing is that the entire shared Library has to fully download before a user file can begin playing. In this way, runtime sharing isn't good for many or large items. You're about to learn the steps to create and use shared items in the runtime mode. In Hour 23, "Working on Large Projects and in Team Environments," you'll walk through a task involving authortime sharing. How to Share Library Items at RuntimeSharing items at runtime involves two basic steps. First, you need to create the Library containing items to be shared. Then, in each file that will use the shared items, you need to establish a link to the source. Try It Yourself: Prepare Items to Share at Runtime In this task you'll create a Library containing items that can be shared. Follow these steps:
Now you can use the shared items in any other movie. Inside the other movies, the items simply need to have the Import for Runtime Sharing check box selected. In the following task, you'll start using the items from the shared Library, and then it should start to make sense. Try It Yourself: 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:
What's the big deal? In the preceding task, you have two files, and one's bigger than the other. So what? First of all, you can repeat the preceding 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. In addition, you can change the contents of shared.fla maybe change the bitmap or the clip 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. In the next task, you'll give it a try. (If you want to first repeat the preceding task but name your file user2.fla, you may.) Try It Yourself: Update Shared Items in a Library In this task, you'll learn how to update the contents of a shared Library. Follow these steps:
The preceding task was almost too easy. You simply created a new Library item in the master shared Library file (shared.fla), made sure it would export, and gave it an identifier name that matched the old one. Then, as soon as you exported the .swf, it worked. Basically, each user file doesn't care what's inside the master shared Library; it simply looks for items that match identifier names. For example, if you have a movie clip that contains English language text and swap it with one that contains Spanish, as long as the identifier is the same, it will work fine (it will just appear in a different language). Although you are probably starting to see how shared Library items can enhance productivity, remember that their other benefit is file size savings. The shared.swf file downloads only once. This might make you want to include larger items (such as sounds and raster graphics). But you should know that when sharing items, the source (shared Library) must download entirely before the user files begin to play. For this reason, you really should use loadMovie or the MovieClipLoader object for larger elements so that you can control and monitor their downloading (as you did in an earlier task this hour). The most appropriate time to use runtime sharing is when you have lots of small items that you expect might need to change periodically for example, a seasonal icon used on several different pages of your website. The icon (set to Export for Runtime Sharing) could change from themes for Halloween to Thanksgiving to New Year's. Basically, all the upfront work in runtime sharing can be very useful, provided that you use the same styles and assets throughout many files. Runtime sharing also means that all the team members could be given copies of the latest version of shared.swf to use on their computers. In the end, when everything is published, the latest version of shared.swf will be used by everyone. All it takes is a little planning. |
< Day Day Up > |