Sample Implementation - MACROMEDIA FLASH MX 2004-FLASH JAVASCRIPT DICTIONARY Manual

Flash javascript dictionary
Hide thumbs Also See for FLASH MX 2004-FLASH JAVASCRIPT DICTIONARY:
Table of Contents

Advertisement

{
extern void MM_Init();
char **envPtr = (char **)env;
char **mmPtr =
char **envEnd = (char **)((char *)envPtr + envSize);
char **mmEnd =
\
/* Copy fields from env to mmEnv, one pointer at a time */
while (mmPtr < mmEnd && envPtr < envEnd)
*mmPtr++ = *envPtr++;
/* If env doesn't define all of mmEnv's fields, set extras to NULL */
\
while (mmPtr < mmEnd)
*mmPtr++ = (char *)0;
/* Call user's MM_Init function */
MM_Init();
}
#endif /* _MM_JSAPI_H_ */

Sample implementation

Included with this documentation is a set of files (Sample.zip for Windows, Sample.sit for
Macintosh) that you can use to test the process of building a DLL. (You can download the file at
www.macromedia.com/go/jsapi_info_en).
To see how the process works without actually building the DLL, you can do the following:
Store the Sample.jsfl file in the Commands directory (see
JavaScript API" on page
Store the Sample.dll file in the External Libraries directory (see
works" on page
In the Flash authoring environment, select Commands > Sample. The trace statement in the
JSFL file sends the results of the function defined in Sample.dll to the Output panel.
This section discusses the development of the sample. In this case, the DLL contains only one
function, which adds two numbers. The C code is shown in the following example:
// Source code in C
// Save the DLL or shared library with the name "Sample"
#include <windows.h>
#include <stdlib.h>
#include "mm_jsapi.h"
// A sample function
// Every implementation of a Javascript function must have this signature
JSBool computeSum(JSContext *cx, JSObject *obj, unsigned int argc, jsval
*argv, jsval *rval)
{
374
Chapter 4: C-Level Extensibility
(char **)(&mmEnv);
(char **)((char *)mmPtr
17).
369).
+ sizeof(MM_Environment));
"Overview of the Macromedia Flash
"How integrating C functions
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents