
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
408
|
Chapter 16: ActionScript Authoring Environment
to the .fla file in any way. To append or insert script text instead of replacing it, you
must manually copy and paste the text from an external text-editing application.
#include (Compile-Time Import)
When we export (compile)a.swf file from a .fla file, we can incorporate code from an
external text file using the
#include directive. For information on using #include, see
the Language Reference.
Shared Library (Runtime Import)
To import code from an external source while a movie is actually playing, we must
create a shared library .swf file with a movie clip containing the code to import.
Runtime import offers the most flexible approach to sharing code across movies,
because it does not require recompilation of the movies that import the shared code;
when the shared library .swf file is updated, the movies that link to it reflect the
update automatically.
The following procedures describe how to share a simple test function from a movie
called codeLibrary.swf to a movie called myMovie.swf. We’ll create the codeLibrary.swf
movie first:
1. Create a new Flash document.
2. Create a new movie clip symbol named sharedFunctions.
3. On frame 1 of the sharedFunctions clip, add the following code:
function test () {
trace("The shared function, test, ...