Data types
541
After writing this code, build the DLL file or shared library, and store it in the appropriate
External Libraries directory (see
“Integrating C functions” on page 534
). Then create a JSFL
file with the following code, and store it in the Commands directory (see
“Saving JSFL files”
on page 7
).
// JSFL file to run C function defined above.
var a = 5;
var b = 10;
var sum = Sample.computeSum(a, b);
fl.trace("The sum of " + a + " and " + b + " is " + sum );
To run the function defined in the DLL, select Commands > Sample in the Flash authoring
environment.
Data types
The JavaScript interpreter defines the following data types:
■
JSContext
■
JSObject
■
jsval
■
JSBool
typedef struct JSContext JSContext
A pointer to this opaque data type passes to the C-level function. Some functions in the API
accept this pointer as one of their arguments.
typedef struct JSObject JSObject
A pointer to this opaque data type passes to the C-level function. This data type represents an
object, which might be an array object or some other object type.
typedef struct jsval jsval
An opaque data structure that can contain an integer, or a pointer to a float, string, or object.
Some functions in the API can read the values of function arguments by reading the contents
of a
jsval
structure, and some can be used to write the function’s return value by writing a
jsval
structure.
Summary of Contents for FLASH 8-EXTENDING FLASH
Page 1: ...Extending Flash...
Page 38: ...38 Top Level Functions and Methods...
Page 532: ...532 Objects...
Page 554: ...554 C Level Extensibility...