Creating Shared Libraries

I l @ ve RuBoard

Flash provides two ways to share library assets. In author-time sharing , Flash authors can grab symbols (or other assets) from centralized source files and use those symbols in the movies they are creating. In run-time sharing , symbols (and other assets) used in one or more movies reside in a central location, from which the Flash Player downloads the symbols for playback.

For the following exercises, create two movies. Name them for their functionsfor example, ItemsToShare.fla and UsingSharedItems.fla. In the file ItemsToShare, create one symbol named Square and another named Rectangle, and place an instance of each symbol on the Stage. In the file UsingSharedItems, create one symbol named Circle and another named Oval, and place an instance of each symbol on the Stage. Save both files in the same folder; call it SharingTest.

To access a shared symbol while authoring:

  1. In the destination file (UsingSharedItems.fla), select the symbol named Circle in the Library window.

  2. From the Options menu in the top-right corner of the Library window, choose Properties.

    The expanded/advanced version of the Symbol Properties dialog box appears (Figure 6.44).

    Figure 6.44. The expanded Symbol Properties dialog box contains all the advanced symbol properties, such as linkage to source files for authoring and export/import of symbols for run-time sharing.

    graphics/06fig44.gif

  3. In the Source section of the dialog box, click the Browse button.

    The Open dialog box appears.

  4. Navigate to the source file (ItemsToShare.fla), select it, and click Open.

    The Select Source Symbol dialog box appears, listing the symbols in the source file (Figure 6.45).

    Figure 6.45. In the Select Source Symbol dialog box, select a "super" master symbol to be shared while authoring a destination file (top). Flash automatically enters the pathway to the source file in the Source section of the Symbol Properties dialog box (bottom).

    graphics/06fig45.gif

  5. Select the symbol named Square.

  6. Click OK.

    Flash returns you to the Symbol Properties dialog box. The Source section now lists the symbol name and the path to the source file.

  7. In the Name field, enter a new name for the symbol, such as Square_SharedAuthoring .

    Flash makes no obvious indication in either the source or destination library that a symbol is linked. For your own tracking, you may want to alter the names of linked symbols to remind you of that fact.

  8. In the Source section of the dialog box, check the Always Update Before Publishing checkbox (Figure 6.46).

    Figure 6.46. With author-time shared symbols you can simply bring a shared symbol into your destination fill; and create no further link to the source file; or you can create a link, so that changes made to the shared symbol in its source file also get made in the destination file when it's published. Check Always Update Before Publishing if you want to incorporate new changes into the source symbol when you publish your movie.

    graphics/06fig46.gif

    When you choose this setting, Flash takes the content of the latest version of the symbol from the source file and uses it to update the linked symbol in the destination file any time you publish or test the destination movie.

  9. Click OK.

    In the library of the destination movie (UsingSharedItems.fla), Flash replaces the content of the master symbol named Circle with the content of the source symbol named Square. Any instances of Circle in use in the destination movie get updated as well (Figure 6.47). All instances retain their individual positioning, sizing, and color effects.

    Figure 6.47. When you link the symbol named Circle to the author-time shared symbol named Square (top), Flash replaces the circle with the square. Unless you've renamed the Circle symbol, it's still called Circle in the destination file. You can give the symbol a name that indicates it's linked to another symbol (bottom).

    graphics/06fig47.gif

    Now any changes you make in the Square symbol in the source file get incorporated into the destination file when you publish the destination file.

graphics/01icon02.gif Tip

  • Earlier in this chapter, you learned to swap symbols within a single movie while retaining individual instance modifications. You can use author-time sharing as a sort of super symbol swap, bringing in a symbol that's not currently part of your document. Follow the steps in the preceding exercise, but omit step 8. Flash replaces the content of your selected symbol just once; future changes to the symbol in the source file will not affect the destination file.


To define symbols as shared for run time:

  1. Open the source file (ItemsToShare.fla).

  2. Open the Library window.

  3. From the list of symbols, select the symbol to be shared: Rectangle.

  4. From the Options menu in the top-right corner of the Library window, choose Linkage (Figure 6.48).

    Figure 6.48. Choose Linkage from the Library window's Options menu to define a shared symbol.

    graphics/06fig48.gif

    The Linkage Properties dialog box appears.

  5. From the list of linkage options, select Export for Runtime Sharing (Figure 6.49).

    Figure 6.49. In the Linkage Properties dialog box, select Export for Runtime Sharing to make a symbol available for sharing in other Flash movies (top). Fill in the identifier and URLfor the symbol (bottom). Flash uses that information to locate and control the symbol. (The identifier must not contain any spaces. The URLis the pathway to the location of the source movie's Player file.)

    graphics/06fig49.gif

    The name of the selected symbol appears in the Identifier field.

  6. Enter an identifier for this shared symbol, such as Rectangle_SharedRuntime .

    Do not include spaces in the identifier.

  7. In the URL field enter the pathname for the published version of the source file. For this exercise, enter ItemsToShare.swf .

    Because for this exercise, the source and destination files live in the same folder and their Player (.swf) files will live there too (see the following exercise)you can simply enter the name of the source Player (.swf) file. In real life, you will need to enter the path to the location where you will post the .swf file of shared symbols.

  8. Click OK.

  9. Save the file.

graphics/01icon02.gif Tip

  • You can define a symbol's linkage as Export for Runtime Sharing when you create the symbol. When you choose Insert > Create New Symbol or Insert > Convert to Symbol, the Symbol Properties dialog box appears. The Export linkage options are available in the expanded view of the dialog box. Click the Advanced button if those options are not visible.


After creating and saving shared symbols in the Flash (.fla) file, you must create a Player (.swf) version of the file to make the shared items available for use in other movies.

To make shared symbols available to other movies during playback:

  1. Open the source file from the preceding exercises (ItemsToShare.fla).

  2. From the File menu, choose Publish Settings.

    The Publish Settings dialog box appears.

  3. Click the Formats tab.

  4. Check the Flash (.swf) checkbox (Figure 6.50).

    Figure 6.50. In the Publish Settings dialog box, check the Flash (.swf) checkbox to publish a .swf file that contains the shared library items.

    graphics/06fig50.gif

    For the purpose of creating shared libraries, this checkbox is the only one that must be checked. To learn more about the various publishing options and settings, see Chapter 16.

  5. Click the Publish but on.

    Flash exports the movie to a Flash Player file (ItemsToShare.swf) that contains the shared library and puts it in the same folder as the original file (SharingTest).

  6. Click OK.

graphics/01icon02.gif Tip

  • To create a Flash Player file quickly, without going through the publishing process, all you need to do is test your movie. Choose Control > Test Movie. Flash creates a Player file, using default settings, and puts it in the same location as the .fla file.


To add shared run-time symbols to your movie:

  1. Open both the source file (ItemsToShare.fla) and the destination file (UsingSharedItems.fla).

  2. Open the Library window for each file.

  3. Drag the Rectangle symbol from the source's Library window to the Library window of the open destination document.

    The shared symbol becomes part of the destination document's library. Flash automatically sets the symbol's linkage properties to Import for Runtime Sharing and enters the same identifier and URL that you entered when you originally made the symbol available for export as a shared symbol.

graphics/01icon02.gif Tips

  • To verify that the shared symbol made it into the document with the correct links, open the library for the destination file. Select the symbol. From the Library window's Options menu, choose Linkage. In the Linkage Properties dialog box, the symbol name should already appear, and the Import for Runtime Sharing checkbox should already be checked (Figure 6.51).

    Figure 6.51. Dragging a run-time shared symbol into a destination file (top) creates the appropriate linkage automatically. Access the Linkage Properties dialog box, and you can see that Flash has filled in the identifier and URLfor the shared symbol automatically (bottom).

    graphics/06fig51.gif

  • You don't actually have to open the source file itself. You can use the File > Open as Library command to open the source's library and then drag the symbol(s) you need to your destination library.


To link existing symbols in destination files to shared run-time symbols in source files:

  1. With the destination file (UsingShared Items.fla) active, open the Library window.

  2. Select the symbol named Oval (or any symbol that you want to replace with a shared run-time symbol).

  3. From the Options menu in the top-right corner of the Library window, choose Properties.

    The Symbol Properties dialog box appears.

  4. In the Linkage section of the dialog box, select Import for Runtime Sharing.

  5. In the Identifier field, enter the identifier of the symbol you want to usein this case, Rectangle_SharedRuntime.

    You create the link to a particular shared symbol by entering the same identifier you used when you set linkage properties in the source file.

  6. In the URL field, enter the pathname to the published Player file for the source symbol: ItemsToShare.swf.

    This step completes the link for playback.

  7. Click OK (Figure 6.52).

    Figure 6.52. To define run-time symbol linkage manually from within a destination file, select the master symbol in the destination file's library, access the Linkage Properties dialog box, specify Import for Runtime Sharing, and enter the identifier and URLfor the run-time symbol in the source file. When you publish your movie, the linked symbol appears.

    graphics/06fig52.gif

  8. Choose Control > Test Movie.

    Flash publishes the movie and opens the .swf file in the Player. You should now see the linked shared rectangle in the place where the oval symbol was originally.

graphics/01icon02.gif Tip

  • You can define a symbol's linkage as Import for Runtime Sharing when you create the symbol. When you choose Insert > Create New Symbol or Insert > Convert to Symbol, the Symbol Properties dialog box appears. The Export linkage options are available in the expanded view of the dialog box. Click the Advanced button if those options are not visible.


They'll Thank You for Sharing

Why use sharing? First, author-time sharing can help you control the consistency of elements and ensure that the most up-to-date versions of elements wind up in your finished movie. This practice is especially important when several people work on the same project. Imagine a project with five designers. If you create centralized files with the latest approved versions of all the graphic elements needed for the project, anyone working on the project can grab their symbols from the shared file. As updates get madewhen the client wants to change the logo from red to blue, for examplethe changes need to be made only in the shared source file. At publication time, Flash automatically updates all the instances of that shared logo symbol in all the files that linked to it.

You can think of author-time shared assets as being super symbols; the library of the shared source document becomes, in a sense, the library for all the documents containing symbols linked to it. Just as for individual .fla files, changes to a master symbol in a library update instances of that symbol in that movie; changes to shared symbols in a source file's library update instances of those symbols in all the movies containing links to those symbols. In both cases, the individual instances retain whatever color effects, positioning, or resizing you (or your colleagues) applied to them.

For regular libraries and their symbols, the updates take place immediately. For linked shared symbols, the updates take place on publication. But when you update the shared file, you update all the documents using instances of that symbol.

Note that the actual assets for a symbol linked for authoring purposes reside in each individual library file, whereas all the assets for symbols linked for run time stay in the one source file.

Symbols that are linked for sharing at run time can streamline movie playback/download for the end users who view your movies. These shared symbols are associated with a Flash Player file posted at a specific location accessible to the end user . Any number of published movies (.swf files) can then retrieve the linked symbols from that location.

For run-time sharing, you must create symbol links in two directions. In the file that acts as the source of shared symbols, you must give Flash permission to export the symbol at run time; in the file that links to those shared symbols, you must give Flash permission to import the symbol at run time. In both cases, you must specify the URL (the pathway to the source file's location) and the identifier for the symbol you want to use.

I l @ ve RuBoard


Macromedia Flash MX for Windows and Macintosh. Visual QuickStart Guide
Macromedia Flash MX 2004 for Windows and Macintosh (Visual QuickStart Guides)
ISBN: 0582851165
EAN: 2147483647
Year: 2002
Pages: 243

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