Package | flash.external |
Class | public final class ExtensionContext |
Inheritance | ExtensionContext EventDispatcher Object |
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2.5 |
The ExtensionContext class also provides a static method getExtensionDirectory()
for
accessing the directory in which the extension is installed on the device. It also provides a
property, actionScriptData
, for sharing data with the native implementation of the extension.
Note: AIR applications using the extendedDesktop
profile can use the NativeProcess class
to execute native processes.
See also
Property | Defined by | ||
---|---|---|---|
actionScriptData : Object
The ActionScript object, if any, associated with this context.
| ExtensionContext | ||
constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | ||
functions : Vector.<String> [read-only]
Returns a list of the functions that are available to be called within this native extension context.
| ExtensionContext | ||
knownExtensions : Vector.<String> [static][read-only]
Gets a list of the extension identifiers for ANEs that are registered with the runtime.
| ExtensionContext | ||
prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object |
Method | Defined by | ||
---|---|---|---|
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event.
| EventDispatcher | ||
Calls the native function specified by
functionName . | ExtensionContext | ||
[static]
Creates an ExtensionContext instance for the given extension identifier and context type.
| ExtensionContext | ||
Dispatches an event into the event flow.
| EventDispatcher | ||
Disposes of this ExtensionContext instance.
| ExtensionContext | ||
[static]
Returns the directory in which the extension is installed on the device.
| ExtensionContext | ||
[static]
Gets information about an extension from the ID.
| ExtensionContext | ||
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event.
| EventDispatcher | ||
Indicates whether an object has a specified property defined.
| Object | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | ||
[static]
Loads an extension into the AIR runtime so that it can be created via createExtensionContext.
| ExtensionContext | ||
Indicates whether the specified property exists and is enumerable.
| Object | ||
Removes a listener from the EventDispatcher object.
| EventDispatcher | ||
Sets the availability of a dynamic property for loop operations.
| Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions.
| Object | ||
Returns the string representation of the specified object.
| Object | ||
Returns the primitive value of the specified object.
| Object | ||
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type.
| EventDispatcher |
Event | Summary | Defined by | ||
---|---|---|---|---|
[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active. | EventDispatcher | |||
[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive. | EventDispatcher | |||
The ExtensionContext class provides an interface for calling functions in the native implementation of a native extension for Adobe AIR. | ExtensionContext |
actionScriptData | property |
actionScriptData:Object
[read-write]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2.5 |
The ActionScript object, if any, associated with this context.
You can associate any ActionScript object with an ExtensionContext instance.
The native implementation can also get and set this ActionScript object. Therefore,
you can use actionScriptData
to share data between the ActionScript
side and the native side of an extension.
You can also set the value of actionScriptData
to null
.
public function get actionScriptData():Object
public function set actionScriptData(value:Object):void
Error — The method dispose() was already called
on this ExtensionContext instance.
|
functions | property |
functions:Vector.<String>
[read-only]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 50.0 |
Returns a list of the functions that are available to be called within this native extension context. This is based on the list of functions passed to the AIR runtime within the native context initialization method.
Implementation public function get functions():Vector.<String>
knownExtensions | property |
knownExtensions:Vector.<String>
[read-only]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 50.0 |
Gets a list of the extension identifiers for ANEs that are registered with the runtime.
Implementation public static function get knownExtensions():Vector.<String>
call | () | method |
public function call(functionName:String, ... args):Object
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2.5 |
Calls the native function specified by functionName
.
Any additional arguments are passed to the native function.
functionName:String — A name that represents a function in the native implementation.
This name is not necessarily the actual name of the native function, but any name
agreed to between the ActionScript side and native side of the extension.
|
|
... args — A list of arguments for the native function. These arguments can be
any ActionScript objects: primitive types or ActionScript class objects. The types and
order of the arguments are agreed to between the ActionScript side and native side of
the extension.
|
Object —
The value returned by the native function. The return value is null
if the native function has no return value or returns an invalid object reference.
|
ArgumentError — No function corresponds to the name given by functionName .
|
|
Error — The method dispose() was already called
on this ExtensionContext instance. This error is also thrown if the native function
returns an invalid object reference.
|
createExtensionContext | () | method |
public static function createExtensionContext(extensionID:String, contextType:String):ExtensionContext
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2.5 |
Creates an ExtensionContext instance for the given extension identifier and context type.
ParametersextensionID:String — The extension identifier of the extension. This identifier has the same
value as the id element in the extension descriptor file. Application developers also
use this value in the extensionID element in the application descriptor file.
All extensions share a single, global namespace. Therefore, to avoid name conflicts,
use reverse DNS notation for the extension identifier.
|
|
contextType:String — The context type of the extension. Depending on the context type, the native
implementation can perform different initializations. These differences can include the native
implementation specifying a different set of available native functions that the ActionScript
side can call. The value of the context type is any string agreed to between the ActionScript
side and the native side of the extension. Simple extensions often have no use for different context types.
In those cases, pass an empty string "" or null for the contextType value.
|
ExtensionContext —
The new ExtensionContext instance. Returns null if no extension with the given
extensionID value is available or if the context initializer function specified
in the extension.xml document for the given extensionID cannot be found or run.
|
ArgumentError — The extensionID parameter is null or is not a valid extension ID.
|
dispose | () | method |
public function dispose():void
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2.5 |
Disposes of this ExtensionContext instance.
The runtime notifies the native implementation, which can release any associated
native resources. After calling dispose()
, the code cannot call the
call()
method and cannot get or set the actionScriptData
property.
getExtensionDirectory | () | method |
public static function getExtensionDirectory(extensionID:String):File
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2.5 |
Returns the directory in which the extension is installed on the device.
Sometimes an extension includes resources such as images that you want to access from the extension's ActionScript code. Sometimes the code also requires information that is available in the extension descriptor file, such as the extension version number. You can use this method to access the base directory of the extension.
Regardless where the extension is on the device, the extension's files are always in the same location relative to this base directory of the extension. Using the File instance that this method returns, you can navigate to and manipulate specific files included with the extension.
The extension directory has the following structure:
extension base directory/ platform independent files META-INF/ ANE/ extension.xml platform name/ platform-dependent files and directories
The extension directory location depends on whether the extension is available through application-bundling or device-bundling as follows:
An exception to using getExtensionDirectory()
exists for native extensions for iOS devices.
The resources for these extensions are not located in the extension directory.
Instead, they are located in the top-level application directory.
extensionID:String — The extension identifier of the extension. This identifier has the same
value as the extensionID parameter in createExtensionContext() .
|
File —
A File instance for the directory in which the extension is installed.
|
TypeError — Parameter extensionID must not be null.
|
|
ArgumentError — The value specified for argument extensionID is invalid.
The directory does not exist.
|
getExtensionInfo | () | method |
public static function getExtensionInfo(extensionID:String):ExtensionInfo
Language version: | ActionScript 3.0 |
Runtime version: | AIR 50.0 |
Gets information about an extension from the ID. This allows an ANE user to check whether an ANE has
been loaded and to find out other information about the extension, by checking the ExtensionInfo
details.
extensionID:String — The extension identifier for the ANE being queried.
|
ExtensionInfo —
The ExtensionInfo object relating to this ANE, or null if there is no extension
that has the requested identifier.
|
loadExtension | () | method |
public static function loadExtension(extensionID:String, aneFolder:File):Boolean
Language version: | ActionScript 3.0 |
Runtime version: | AIR 50.0 |
Loads an extension into the AIR runtime so that it can be created via createExtensionContext.
ParametersextensionID:String — The extension identifier of the extension. This identifier has the same
value as the id element in the extension descriptor file. Application developers also
use this value in the extensionID element in the application descriptor file.
All extensions share a single, global namespace. Therefore, to avoid name conflicts,
use reverse DNS notation for the extension identifier.
|
|
aneFolder:File — The folder in which the extension descriptor file is located. This parameter may
be null where the request is to load an already-defined extension that was set up as a delayed-load
extension; otherwise, this location is checked for an extension descriptor file that defines the ANE
with the given extensionID , and if successful the ANE is then loaded in dynamically.
|
Boolean —
Success if the ANE was loaded in successfully, such that the client code may now call any
function that references the ANE's library/interface code.
|
ArgumentError — The extensionID parameter is null or is not a valid extension ID,
or if the aneFolder is non-null but does not reference a valid folder location.
|
status | event |
flash.events.StatusEvent
flash.events.StatusEvent.STATUS
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2.5 |
The ExtensionContext class provides an interface for calling functions in the native implementation of a native extension for Adobe AIR. You can use this class only in ActionScript classes that are part of the extension.
AIR profile support: This feature is supported
on mobile devices starting in AIR 3. It is also supported starting in AIR 3 on
desktop devices in applications that use the extendedDesktop
device profile.
It is supported on AIR for TV devices starting in AIR 2.5 in applications that use the extendedTV
device profile.
A native extension is a combination of:
You can create a native extension to:
Use the ExtensionContext class in the ActionScript side of an extension to access
the native side of the extension. First, create an instance of the ExtensionContext class.
To do so, call the static method ExtensionContext.createExtensionContext()
.
After creating the ExtensionContext instance, use the instance's call()
method to
call a native function.
When you are done with an ExtensionContext instance, call dispose()
to release
any associated native resources. Without an explicit call to dispose()
,
the runtime garbage collector calls dispose()
when it disposes of the instance.
An explicit call to dispose()
typically occurs much sooner than waiting for the
garbage collector.
An ExtensionContext instance can listen for StatusEvent events that the native code dispatches when some asynchronous event occurs in the extension's native implementation. Since the ExtensionContext class derives from EventDispatcher, it can in turn dispatch events.
Defines the value of the type
property of a status
event object.
This event has the following properties:
Property | Value |
---|---|
bubbles | false |
cancelable | false ; there is no default behavior to cancel. |
code | A description of the object's status. |
currentTarget | The object that is actively processing the Event object with an event listener. |
level | The category of the message, such as "status" , "warning" or "error" . |
target | The object reporting its status. |