Dynamically Importing Cast Libraries

Date:    Fri, 1 Aug 1997 22:31:06 -0700
From:    "Terry R. Schussler" 
Subject: Dynamically Importing Cast Libraries (was: Question about castLib...)

>Hi all, I have a project that I need to create a new castLib and link this
>new castLib to my movie.
>
>Can I create a new castLib and linked this castLib on the fly with Lingo?
Warning: The following is an undocumented "hack" and may not work in all situations - I simply haven't tried them yet. Nor is this guaranteed to work in all playback environments. In short: try it out carefully to see if applies to your situation.

Dynamically Importing Cast Libraries
Director developers have frequently inquired about methods for dynamically associating external cast libraries with a currently running movie. This is a useful concept -- enabling projects to make use of a _potentially_ existing castlibrary without requiring that it be "pre-attached" or linked in advance during the authoring of the movie itself.

One technique involves creating a "dummy" external castlibrary and then linking to it during authoring as a temporary placeholder. Then during playback, you can "set the filename of castlib" to alter the link to another external castlibrary (perhaps located on the user's hard drive instead of a CD-ROM) which contains other media you wish to use. The downside of this approach is that you still need to establish at least one pre-existing linked external castlibrary in the movie before you can perform dynamic substitution by changing the link reference.

Another "undocumented" technique for doing this dynamic linking can now be considered as perhaps a better alternative. What's the one way that you can dynamically associate a wide array of external media types with a currently running Director movie? That's right, the "importFileInto" Lingo command. This well known command has the undocumented benefit of allowing a developer to reference an external cast library as the media to "import." The syntax you will need to use is:

  importFileInto member memberReference, externalCastLibraryReference
where 'member memberReference' is any valid member reference and 'externalCastLibraryReference' is the full or partial path and filename reference to an external cast library.

What this technique does is cause Director to dynamically attached the specified external castlibrary as a _linked_ castlibrary.

Examples:

  importFileInto member 99, "Macintosh HD:MEDIA:mycache.cst"
  importFileInto member 1000 of castLib "stuff", "/extras/moredata.cst"
  importFileInto member 8765, "cooldata.cst"
Notes:
The contents of the castmember at the specified 'member memberReference' will be completely erased. The castmember reference is only provided as a way to allow the importFileInto command to parse properly. Therefore, it is recommended that you simply reference an unused castmember. It is also suggested that you reference the castmember by number since its name will be erased during the import process and you will not be able to refer to the castmember by name again.

You can execute this command multiple times in a single session, including importing the same external castlibrary. Each time you execute this command it will create another link to the specified external castlibrary.

Once a castlibrary is linked in this manner, it cannot be unlinked. Any link reference created to an external castlibrary will not be saved unless the movie itself is saved to disk _after_ the importFileInto command is executed. In projectors, you can use the 'saveMovie' Lingo command to do this.

I believe that setting 'the updateMovieEnabled' property = TRUE will also cause any new link references created to be saved to disk automatically during playback but I have not carefully tested this.

Known Supported Variations:
Director Version Authoring(1) Projector(2) Shockwave
MACINTOSH
5.0YES YES Untested
5.0.1YES YES Untested
6.0YESYESNO (using r159 build of Shockwave for Director 6)
WINDOWS
(Note: Windows 3.1 supports a maximum limit of 13 external castlibraries.)
5.0 YES YES Untested
5.0.1 YES YES Untested
6.0YES(3)YESUntested
(1)Appears to support .CST files but not .CXT nor .CCT files.
(2) Appears to support .CST and .CXT files but not.CCT files.
(3)This variation does not work in Windows 3.1 since Director 6.0 does not support this OS for authoring.

This material is ©1997 by g/matter, inc. with license to the readers of DIRECT-L for personal use.