createContext
FREContext createContext( String contextType )
Creates
an FREContext object.
The AIR runtime calls the Java
createContext()
method
after the extension invokes the ActionScript
ExtensionContext.createExtensionContext()
method.
The runtime uses this context returned for subsequent method invocations.
This
function typically uses the
contextType
parameter
to choose the set of methods in the native implementation that the
ActionScript side can call. Each context type corresponds to a different
set of methods. Your extension can create a single context; multiple
context instances that provide the same set of features, but with
instance-specific state; or multiple context instances that provide different
features.
Parameters:
-
contextType
-
A string identifying the type of the context. You define
this string as required by your extension. The context type can
indicate any agreed-to meaning between the ActionScript side and
native side of the extension. If your extension has no use for context
types, this value can be
null
. This value is a
UTF-8 encoded string, terminated with the null character.
Returns:
-
FREContext
-
the extension context object.
Example:
The
following example returns a context object based on the
contextType
parameter.
If the
contextType
is the string, “TypeA”, the
function returns a unique FREContext instance each time it is called.
For other values of
contextType
, the function only
creates a single FREContext instance and stores it in the private
variable
bContext
.
private FREContext bContext;
public FREContext createContext( String contextType ) {
FREContext theContext = null;
if( contextType == "TypeA" )
{
theContext = new TypeAContext();
}
else
{
if( bContext == null ) bContext = new TypeBContext();
theContext = bContext;
}
return theContext;
}