C
HAPTER
3: Creating a Flash UI for Plug-ins
Communication between plug-ins and extensions
32
Using the PlugPlug API
The PlugPlug library exposes these functions to C++ plug-ins. For complete reference details, see
SDK_root
/samplecode/common/includes/SDKPlugPlug.h
. The class
SDKPlugPlug
wraps these
functions for ease of use.
X
To receive CSXS Events of a certain type in your C++ Plug-in, register a callback function for that event
type using
SDKPlugPlug::AddEventListener()
,
before
loading the extension. For example:
static void OkClickedFunc (const csxs::event::Event* const event,
void* const context);
AddEventListener("com.adobe.csxs.events.OkClicked", OkClickedFunc, NULL);
Z
The first parameter is the event type, the second is the callback function, and the third is a
user-specific context pointer or NULL.
Z
When the extension sends an event to the plug-in, it passes relevant data as a
const char*
. Your
callback function must parse this string into data items useful to the plug-in.
X
Before unloading the extension, you must use
SDKPlugPlug::RemoveEventListener()
to remove
any event listeners you have registered. For example:
RemoveEventListener("com.adobe.csxs.events.OkClicked", OkClickedFunc, NULL);
X
Your plug-in can load and unload the related extension using
SDKPlugPlug::LoadExtension()
and
SDKPlugPlug::UnloadExtension()
.
CSXS SWC
PlugPlug
Extension
Plug-in
call
PlugPlugDispatchEvent()
PlugPlugDispatchEvent()
delegateEventToListener()
PlugPlugLoadExtension()
Uses the Stage Manager to load a given extension, making the
Flash UI visible in the application and setting the window
properties as specified in the extension manifest.
PlugPlugUnloadExtension()
Uses the Stage Manager to unload a given extension (when
implemented), so that the Flash UI is no longer visible in the
application.
PlugPlugDispatchEvent()
Dispatches a CSXS Event, which contains related data passed as a
string (
const char*
).
PlugPlugAddEventListener()
Registers the plug-in to receive a given event type, and defines
the callback function for that event.
PlugPlugRemoveEventListener()
Removes the listener for a given event type.