
CHAPTER 7: Integrating External Libraries ExternalObject object 201
automatically defined, and you can access the properties and methods through an instance of that
class. For example:
anotherlib= new ExternalObject ("lib:" + filespec); // load the library
alert(anotherlib.version) ;
// instantiate library-defined class
var myObject = new MyNewClass() ;
// access functions from instance
var a = myObject.method_abc(1,2.0,true,"this is data") ;
alert(a) ;
anotherlib.unload() ;
For details of how to define functions for direct access through the ExternalObject object, see
“
Defining entry points for indirect access” on page 206.
ExternalObject object
You specify the name of the library in the constructor. The constructor searches for the named library
using the paths defined in the static property
ExternalObject.searchFolders.
If you are having difficulty loading your library as an
ExternalObject, set the property
ExternalObject.log to true, then call ExternalObject.search('lib:myLibrary'). This function
performs the search, and the log reports the paths that have been searched to the ExtendScript Toolkit
Console.
Before loading the library, the current folder is temporarily switched to the location of the found
executable file.
X In Mac OS, the current directory is set to the bundle or framework folder for the library.
X In Windows and UNIX, the current directory is set to the folder that contains the library.
ExternalObject constructor
obj = new ExternalObject ("lib:" + filespec, arg1, ...argn);
For example:
var mylib = new ExternalObject( "lib:myLibrary" );
filespec
The specifier "lib:" is case sensitive, and serves as the marker for dynamic libraries.
Concatenate this to the base name of the shared library, with or without an extension.
ExtendScript appends a file extension if necessary, according to the operating system:
X .dll in Windows
X .bundle or .framework in Mac OS (only Mach-O bundles are supported)
X .so in UNIX (except for HP/UX, where the extension is .sl )
The name of the library is case sensitive in UNIX.
arg1...argn
Optional. Any number of arguments to pass to the library’s initialization routine.
Comentários a estes Manuais