The NativeProcess class and its capabilities are only available to AIR applications installed with a
native installer (extended desktop profile applications). When debugging, you can pass the
AIR profile support: This feature is supported
on applications that are deployed to desktop operating systems via native installers.
The feature is not supported on mobile devices or on AIR for TV devices. You can test
for support at run time using the
AIR applications installed with a native installer (extended desktop profile applications) can also use the
Note: AIR for TV applications using the
#!/usr/bin/python # ------------------------------------------------------------------------------ # Sample Python script # ------------------------------------------------------------------------------ import sys for word in sys.argv: #echo the command line arguments print word print "HI FROM PYTHON" print "Enter user name" line = sys.stdin.readline() sys.stdout.write("hello," + line)
If the
If the
If the NativeProcess does successfully exit, it dispatches a
A NativeProcess instance corresponds to a single process on the underlying operating system. If you want to execute more than one instance of the same operating system process concurrently, you can create one NativeProcess instance per child process.
You can call this method whenever the
The NativeProcess class and its capabilities are only available to AIR applications installed with a
native installer. When debugging, you can pass the
Important security considerations:
The native process API can run any executable on the user's system. Take extreme care when constructing and executing commands. If any part of a command to be executed originates from an external source, carefully validate that the command is safe to execute. Likewise, your AIR application should validate data passed to a running process.
However, validating input can be difficult. To avoid such difficulties, it is best to write a native application (such as an EXE file on Windows) that has specific APIs. These APIs should process only those commands specifically required by the AIR application. For example, the native application may accept only a limited set of instructions via the standard input stream.
AIR on Windows does not allow you to run .bat files directly. Windows .bat files are executed by
the command interpreter application (cmd.exe). When you invoke a .bat file, this command application
can interpret arguments passed to the command as additional applications to launch. A malicious injection
of extra characters in the argument string could cause cmd.exe to execute a harmful or insecure application.
For example, without proper data validation, your AIR application may call
If you call the
The type is IDataInput because data is input from the perspective of the current process, even though it is an output stream of the child process.
The type is IDataOutput because data is output from the perspective of the current process, even though it is an input stream of the child process.
The type is IDataInput because data is input from the perspective of the current process even though it is an output stream of the child process.
Use the
You cannot instantiate the InteractiveIcon class directly. Calls to
the
When an icon is displayed in a given operating system context, the bitmap in the array closest to the displayed size is used (and scaled if necessary). Common sizes include 16x16, 32x32, 48x48, and 128x128. (512x512 pixel icons may be used for some operating system icons in the near future.)
In some contexts, the operating system may use a default system icon
if nothing has been assigned to the
To set or change the icon appearance, assign an array of
BitmapData objects to the
Modifying the
To clear the icon image, assign an empty array to the
Note: When loading image files for an icon, the PNG file format generally provides the best alpha blending. The GIF format supports only on or off transparency (no blending). The JPG format does not support transparency at all.
Some icon contexts support dynamic sizes.
The
Some icon contexts support dynamic sizes.
The
The NativeDragActions constants are used as values for the
In a
The NativeApplication class provides application information, application-wide functions, and dispatches application-level events.
The NativeApplication object is a singleton object, created automatically at startup.
Get the NativeApplication instance of an application with the static property
Note: This event is not dispatched on mobile devices or AIR for TV devices.
The period of time that is considered idle is configurable with the
Specify the period of time for which a user must be idle before this event is dispatched using the
Note: This event is not dispatched on mobile devices or AIR for TV devices.
A
Notes:
The
AIR for TV devices never dispatch the
Note: Calling the NativeApplication
Browser invocation is permitted only if an application specifies the following in the application descriptor file:
When an application is invoked a second time,
another instance of the application is not started. Instead, the first instance
receives an additional invoke event. It is the responsibility of the
application to handle subsequent
Note: All
This method is not supported on platforms that do not support the NativeWindow class.
Under some circumstances determined by the operating system, this method does not activate an application. Most operating systems restrict the ability of an application to activate itself to prevent it from accidentally or maliciously making it impossible for a user to use other applications.
If the operating system allows activation, then the specified window is activated and
brought to the desktop foreground; that is, in front of the windows of other applications.
(If the
The
The activate operation is synchronous.
The function can have any name.
Class-level member functions are not subject to garbage
collection, so you can set
After you successfully register an event listener, you cannot change its priority
through additional calls to
Keep in mind that after the listener is registered, subsequent calls to
You cannot register an event listener for only the target phase or the bubbling phase. Those phases are coupled during registration because bubbling applies only to the ancestors of the target node.
If you no longer need an event listener, remove it by calling
Copying an EventDispatcher instance does not copy the event listeners attached to it. (If your newly created node needs an event listener, you must attach the listener after creating the node.) However, if you move an EventDispatcher instance, the event listeners attached to it move along with it.
If the event listener is being registered on a node while an event is being processed on this node, the event listener is not triggered during the current phase but can be triggered during a later phase in the event flow, such as the bubbling phase.
If an event listener is removed from a node while an event is being processed on the node, it is still triggered by the current actions. After it is removed, the event listener is never invoked again (unless registered again for future processing).
This function call is ignored if the focused object does not implement the command. Only display objects descending from the TextField or HTMLLoader classes currently implement this command.
Note: The
This function call is ignored if the component does not implement the command. Only display objects descending from the TextField or HTMLLoader classes currently implement this command.
This function call is ignored if the component does not implement the command. Only display objects descending from the TextField or HTMLLoader classes currently implement this commands.
The call to the
Note that an
Note: This method is not supported on the iOS operating system.
Note: This method can only be used with file types declared in the
This method is not applicable for AIR for TV devices. If you call it with a file type
declared in the application descriptor, it returns
AIR profile support: This feature is supported
on all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. You can test
for support at run time using the
This function call is ignored if the component does not implement the command. Only display objects descending from the TextField or HTMLLoader classes currently implement this command.
Note: This method can only be used with file types listed in the
This function call is ignored if the component does not implement the command. Only display objects descending from the TextField or HTMLLoader classes currently implement this command.
Note: This method can only be used with file types declared in the
If the active desktop window does not belong
to this application, or there is no active window,
This property is not supported on platforms that do not support the NativeWindow class.
The value of this ID is set in the application descriptor file.
When
This property is not supported on platforms that do not support the NativeWindow class.
Use
The
By default, the idle threshold is 300 seconds (5 minutes). The acceptable range of values is from 5 (5 seconds) through 86,400 (1 day), inclusive.
Application menus are supported when
AIR profile support: This feature is not supported
on mobile devices or AIR for TV devices. See
Note: On Mac OS X, the
This property is not supported on platforms that do not support the NativeWindow class.
The value of this ID is set in the application's publisherid file, which is generated at installation from the certificate chain used to sign the application.
AIR profile support: This feature is supported
on all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. You can test
for support at run time using the
The
If
If
The Mac OS X user interface provides an application "dock" containing icons for applications that are running or are frequently used.
Be sure to use the
When
Be sure to use the
If
If
The Windows user interface provides the "system tray" region of the task bar, officially called
the Notification Area, in which application icons can be displayed. No default icon is shown. You
must set the
Be sure to use the
A value from the SystemIdleMode class to influence the host system's idle mode behavior. This property is only effective for the application with input focus and can only be accessed from content running in the application sandbox.
AIR profile support: This feature is supported
on mobile devices, but it is not supported on desktop operating systems or AIR for TV devices. See
The Updater class is only supported in the desktop profile. It is not supported for
extended desktop applications (applications installed with a native installer), and it is not
supported on the AIR mobile profile or AIR for TV profiles. Check the
Extended desktop application (applications installed with a native installer)
can download a new version of the native installer and launch it using the
Calling this method causes the current application to exit (as if the
The update process relaunches the application whether or not the update is successful. Updates can fail for a variety of reasons, including some that the application cannot control (such as the user having insufficient privileges to install the application). Applications should take care to detect failures and avoid reattempting the same failed update repeatedly. The resulting infinite loop would effectively disable the application. One way to check for a successful update is to write the current version number to a file before starting the update, and then compare that to the version number when the application is relaunched.
When testing an application using the AIR Debug Launcher (ADL) application,
calling the
On Mac OS, to install an updated version of an application, the user needs to have adequate system privileges to install to the application directory. On Windows or Linux, the user needs to have adminstrative privileges.
If the updated version of the application requires an updated version of the runtime, the new runtime version is installed. To update the runtime, a user needs to have administrative privileges for the computer.
Note: Specifying the
AIR profile support: This feature is supported on
desktop operating systems, but it is not supported on mobile devices or AIR for TV devices. See
Not all desktop operating systems have system tray icons. Check
An instance of the SystemTrayIcon class cannot be created. Get the object representing the system tray
icon from the
When system tray icons are supported, the icon will be of type SystemTrayIcon.
Otherwise, the type of
Important: Attempting to call a SystemTrayIcon class method on the
When an icon is displayed in a given operating system context, the bitmap in the array closest to the displayed size is used (and scaled if necessary). Common sizes include 16x16, 32x32, 48x48, and 128x128. (512x512 pixel icons may be used for some operating system icons in the near future.)
In some contexts, the operating system may use a default system icon
if nothing has been assigned to the
To set or change the icon appearance, assign an array of
BitmapData objects to the
Modifying the
To clear the icon image, assign an empty array to the
Note: When loading image files for an icon, the PNG file format generally provides the best alpha blending. The GIF format supports only on or off transparency (no blending). The JPG format does not support transparency at all.
Some icon contexts support dynamic sizes.
The
Some icon contexts support dynamic sizes.
The
A Clipboard object can contain the same information in more than one format.
By supplying information in multiple formats, you increase the chances that another
application will be able to use that information. Add data to a Clipboard object
with the
The standard formats are:
These constants for the names of the standard formats are defined in the ClipboardFormats class.
When a transfer to or from the operating system occurs,
the standard formats are automatically translated between
You can use application-defined formats to add
When it is computationally expensive to convert the information to be transferred into a
particular format, you can supply the name of a function that performs the conversion.
The function is called if and only if that format is read by the receiving component or application.
Add a deferred rendering function to a Clipboard object with the
Note for AIR applications: The clipboard object referenced by the event objects dispatched for HTML drag-and-drop and copy-and-paste events are not the same type as the AIR Clipboard object. The JavaScript clipboard object is described in the AIR developer's guide.
Note for Flash Player applications: In Flash Player 10, a paste operation from the clipboard first
requires a user event (such as a keyboard shortcut for the Paste command or a mouse click on the Paste command
in a context menu).
On Linux, clipboard data does not persist when an AIR application closes.
Note: Because of security restrictions on accessing clipboard data, this example
does not work in Flash Player. In Flash Player, you can only call the
Create Clipboard objects to hold the data of a native drag-and-drop gesture in Adobe AIR. Clipboard objects can be used for only one drag-and-drop gesture; they cannot be reused.
Do not create a Clipboard object for copy-and-paste operations. Use the single
Note: For copy-and-paste operations involving the operating system clipboard,
use the
Flash Player requires that the
When a standard data format is accessed, the data is returned as a new object of the corresponding Flash data type.
When an application-defined format is accessed, the value of the
Use the constants in the ClipboardFormats class to reference the standard format names.
Use a handler function to defer creation or rendering of the data until it is actually accessed.
The handler function must return the appropriate data type for the specified format:
The handler function is called when and only when the data in the specified format is read. Note that in some cases, the operating system calls the function before a drop occurs. For example, when you use a handler function to provide the data for a file dragged from an AIR application to the file system, the operating system calls the data handler function as soon as the drag gesture leaves the AIR application—typically resulting in an undesireable pause as the file data is downloaded or created. You can use a URLFilePromise for this purpose instead.
Note that the underlying data can change between the time the handler is added and the time the data is read unless your application takes steps to protect the data. The behavior that occurs when data on the clipboard represented by a handler function is read more than once is not guaranteed. The clipboard might return the data produced by the first function call or it might call the function again. Do not rely on either behavior.
In the application sandbox of Adobe AIR,
To add data directly to this Clipboard object, use the
Note: On Mac OS, when you set the
In the application sandbox of Adobe AIR,
Different representations of the same information can be added to the clipboard as different formats, which increases the ability of other components or applications to make use of the available data. For example, an image could be added as bitmap data for use by image editing applications, as a URL, and as an encoded PNG file for transfer to the native file system.
The data parameter must be the appropriate data type for the specified format:
Custom format names cannot begin with "air:" or "flash:". To prevent name collisions when using custom formats, you may want to use your application ID or a package name as a prefix to the format, such as "com.example.applicationName.dataPacket".
When transferring within or between applications, the
Note: The standard formats are always converted to native formats when data is pasted or
dragged outside a supported application, so the value of the
To defer rendering of the data for a format, use the
Note: On Mac OS, when you set the
String constants for the names of the standard formats are defined in the ClipboardFormats class. Other, application-defined, strings may also be used as format names to transfer data as an object.
Any data pasted to the system clipboard is available to other applications. This may include insecure remote code running in a web browser.
Note: In Flash Player 10 applications, a paste operation from the clipboard first
requires a user event (such as a keyboard shortcut for the Paste command or a mouse click on the Paste command
in a context menu).
The
You should always clear the clipboard before writing new data to it to ensure that old data in all formats is erased.
The
A file promise is a drag-and-drop clipboard format that allows a user to drag a file that does not yet exist out of an AIR application. AIR uses the methods and properties defined by the IFilePromise interface to access the data to be written when the file promise is dropped.
When a file promise is dropped on a suitable target, AIR calls the IFilePromise
If the data from the data provider is accessed synchronously, such as with a ByteArray, AIR reads the amount of data indicated by the IDataInput
If the data from the data provider is accessed asynchronously, such as with a Socket, AIR uses events dispatched by the provider to regulate the process of reading the data and writing it to the file. Data is read at each progress event until a complete or a close event is received. The runtime listens for the following events (but a data provider does not need to dispatch every event):
Custom data provider classes should dispatch either a
The methods defined by IFilePromise are only intended to be called by the AIR runtime after a drag and drop operation has completed. Developers should not typically call these methods from their own code.
Note: The URLFilePromise class, available in the air.desktop library implements the IFilePromise interface and uses the URLStream as a data provider. The air.desktop library is included as separate SWF and SWC files in the AIR SDK.
No methods will be called on the object reference returned by
The data provider object must implement the IDataInput interface, which defines methods for reading
data. If the IFilePromise
You can also provide an object of a custom class that implements the required interfaces (or extends another class that implements them).
If
If
This property must provide a valid path or an argument error is thrown when the file promise is dropped.
The path can include subdirectories, which are resolved based on the drop location. The subdirectories are created,
if needed. When including subdirectories, use the
Note: To allow client code to set the path, you can implement a setter function with the signature:
Native process access is only available to AIR applications installed with native installers (applications in the extended desktop profile).
Each string in the
Note: On Mac OS, to launch an executable within an application bundle, be sure to have the path of the File object include the full path the the executable (within the bundle), not just the path to the app file.
On Android, the application must specify the Android permissions for DISABLE_KEYGUARD and WAKE_LOCK in the application descriptor or the operating system will not honor this setting.
The transfer mode provides a hint about whether to return a reference or a copy when accessing an object contained on a clipboard.
The following kinds of data can be transferred:
Note: all NativeDragManager members are static. An instance of this class does not need to be created.
A drag-and-drop operation is a user interface gesture that begins with the user clicking a visible item and dragging it elsewhere. During the drag gesture, interactive objects on the display list dispatch native drag events as the gesture moves across the AIR application window. Handlers for these events can call the methods of the NativeDragManager class to indicate whether a dragged item can be dropped on an object. In response, the NativeDragManager changes the mouse pointer to provide feedback to the user.
AIR profile support: This feature is not supported
on AIR for TV devices. Also, it is not supported on all mobile devices. You can test
for support at run time using the
Drag actions
Drag-and-drop gestures are typically used for three types of operations, called actions. Since the meaning of these actions depends on the application context, the runtime does not enforce any particular behavior with respect to actions. However, properly implementing the actions improves the user experience with your application.
The possible actions are:
The allowed actions can be set for a drag gesture by supplying an
If a drop target only implements a single action, the object can set the
When accepting a drop, a potential drop target should specify the action chosen
by setting the
String constants for the action names are defined in the NativeDragActions class.
Sequence of events
A drag gesture is begun by calling the
Gestures between applications
When a drag gesture enters an AIR application window from a non-AIR application,
there is no initiator object to dispatch the
When a drag gesture leaves an AIR application window, there is no target object to dispatch
When a drag gesture moves from one AIR application to another, the initiator and target display objects dispatch events within their separate applications as usual.
Transfering information
The data transfered during a drag-and-drop gesture is contained in a Clipboard object.
This data object is added to the drag operation with the
Security considerations
The security sandboxes of the initiator and potential target objects determine how the
the data being dragged can be accessed. If both objects are in the same sandbox,
then the data can be accessed from any NativeDragEvent object. However,
if the initiator and target objects are in different sandboxes, the data can
only be accessed in the target sandbox within the event
handler for the
This method should be called only when there is a
This function can be called only within a
To start a drag operation:
The initiator object dispatches a
This method can be called only from within a
The
Drag actions are part of a feedback mechanism to allow the initiating and target objects to cooperate in the drag-and-drop exchange. The actions are only a hint to the operating system. It is up to the drag initiator and target objects involved in the transaction to implement the proper behavior.
An initiating object should only allow the actions that it supports. For example, an initiating object should allow the move action only if that object's internal logic removes the source data when a target accepts a drop with a move action.
A new NativeDragOptions object has all properties initialized to
AIR profile support: This feature is supported on
all desktop operating systems, but it is not supported on mobile devices or AIR for TV devices. You can test
for support at run time using the
You can use the DockIcon class to change the appearance of the standard icon; for example, to animate the icon or add informational graphics. You can also add items to the dock icon menu. The menu items that you add are displayed above the standard menu items.
An instance of the DockIcon class cannot be created. Get the object
representing the operating system dock icon from
Not all operating systems have dock icons. Check
Important: Attempting to call a DockIcon class method on the
Calling this method bounces the dock icon if, and only if, the
application is in the background. If the
When an icon is displayed in a given operating system context, the bitmap in the array closest to the displayed size is used (and scaled if necessary). Common sizes include 16x16, 32x32, 48x48, and 128x128. (512x512 pixel icons may be used for some operating system icons in the near future.)
In some contexts, the operating system may use a default system icon
if nothing has been assigned to the
To set or change the icon appearance, assign an array of
BitmapData objects to the
Modifying the
To clear the icon image, assign an empty array to the
Note: When loading image files for an icon, the PNG file format generally provides the best alpha blending. The GIF format supports only on or off transparency (no blending). The JPG format does not support transparency at all.
Some icon contexts support dynamic sizes.
The
Any items in the menu are displayed above the standard items. The standard items cannot be modified or removed.
Some icon contexts support dynamic sizes.
The
An Icon object has one property,
When an icon is displayed in a given operating system context, the bitmap in the array closest to the displayed size is used (and scaled if necessary). Common sizes include 16x16, 32x32, 48x48, and 128x128. (512x512 pixel icons may be used for some operating system icons in the near future.)
In some contexts, the operating system may use a default system icon
if nothing has been assigned to the
To set or change the icon appearance, assign an array of
BitmapData objects to the
Modifying the
To clear the icon image, assign an empty array to the
Note: When loading image files for an icon, the PNG file format generally provides the best alpha blending. The GIF format supports only on or off transparency (no blending). The JPG format does not support transparency at all.