Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 521

Programming actionscript 3.0
Table of Contents

Advertisement

Receiving a function call from ActionScript is a multistep process. Function calls from
ActionScript cause the Shockwave Flash ActiveX control to dispatch its FlashCall event, so a
class (such as the ExternalInterfaceProxy class) that intends to receive calls from a SWF file
needs to define a handler for that event. In the ExternalInterfaceProxy class, the event handler
function is named
_flashControl_FlashCall()
the class constructor, as follows:
private AxShockwaveFlash _flashControl;
public ExternalInterfaceProxy(AxShockwaveFlash flashControl)
{
_flashControl = flashControl;
_flashControl.FlashCall += new
_IShockwaveFlashEvents_FlashCallEventHandler(_flashControl_FlashCall);
}
...
private void _flashControl_FlashCall(object sender,
_IShockwaveFlashEvents_FlashCallEvent e)
{
// Use the event object's request property ("e.request")
// to execute some action.
...
// Return a value to ActionScript;
// the returned value must first be encoded as an XML-formatted string.
_flashControl.SetReturnValue(encodedResponse);
}
The event object (
) has a
e
information about the function call, such as the function name and parameters, in XML
format. This information can be used by the container to determine what code to execute. In
the ExternalInterfaceProxy class, the request is converted from XML format to an
ExternalInterfaceCall object, which provides the same information in a more accessible form.
The ActiveX control's
ActionScript caller; once again, the result parameter must be encoded in the XML format
used by the External API.
property (
request
method is used to return a function result to the
SetReturnValue()
Example: Using the External API with an ActiveX container
, and it is registered to listen for the event in
) that is a string containing
e.request
521

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents