370
Chapter 4: C-Level Extensibility
■
Windows 98:
C:\Windows\Application Data\Macromedia\Flash MX 2004\ <language>\
Configuration\Templates\External Libraries
■
Macintosh OS X:
Hard Drive/Users/<userName>/Library/Application Support/Macromedia/
Flash MX 2004/<language>/Configuration/Templates/External Libraries
4.
Create a JSFL file that calls the functions.
5.
Run the JSFL file from the Commands menu in the Flash authoring environment.
For more information, see
“Sample implementation” on page 374
.
C-level extensibility and the JavaScript interpreter
The C code in the DLL or shared library interacts with the Flash JSAPI at three different times:
•
At startup, to register the library’s functions
•
When the C function is called, to unpack the arguments that are being passed from JavaScript
to C
•
Before the C function returns, to package the return value
To accomplish these tasks, the interpreter defines several data types and exposes an API.
Definitions for the data types and functions that are listed in this section appear in the
mm_jsapi.h file. For your library to work properly, you must include the mm_jsapi.h file at the
top of each file in your library, with the following line:
#include "mm_jsapi.h"
Including the mm_jsapi.h file includes the mm_jsapi_environment.h file, which defines the
MM_Environment structure.
To get a copy of the mm_jsapi.h file, download the sample ZIP or SIT file (see
“Sample
implementation” on page 374
), or copy the following code into a file that you name mm_jsapi.h:
#ifndef _MM_JSAPI_H_
#define _MM_JSAPI_H_
/*****************************************************************************
* Public data types
****************************************************************************/
typedef struct JSContext JSContext;
typedef struct JSObject JSObject;
typedef long jsval;
#ifndef JSBool
typedef long JSBool;
#endif
typedef JSBool (*JSNative)(JSContext *cx, JSObject *obj, unsigned int argc,
jsval *argv, jsval *rval);
/* Possible values for JSBool */
#define JS_TRUE 1
Содержание FLASH MX 2004-FLASH JAVASCRIPT DICTIONARY
Страница 1: ...Flash JavaScript Dictionary ...
Страница 16: ...16 Contents ...
Страница 40: ...40 Chapter 2 Top level functions ...
Страница 368: ...368 Chapter 3 Objects ...
Страница 386: ...386 Chapter 4 C Level Extensibility ...