Pacoteflash.system
Classepublic final class Shell
HerançaShell Inheritance EventDispatcher Inheritance Object

The Shell class allows an application to interact with the operating system shell (for exemplo, the Windows Explorer or the Mac OS X Finder).

The shell is a singleton object, created automatically at application startup. Get the Shell instance of an application with the static property Shell.shell.



Propriedades Públicas
 PropriedadeDefinido por
  activeWindow : NativeWindow
[read-only] Returns the application window that is currently active.
Shell
  applicationDescriptor : XML
[read-only] The contents of the application descriptor file for this AIR application.
Shell
  applicationID : String
[read-only] The application ID of this application.
Shell
  autoExit : Boolean
Specifies whether the application should automatically terminate when all windows have been closed.
Shell
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  icon : InteractiveIcon
[read-only] The application icon.
Shell
  idleThreshold : int
Specifies how many seconds must elapse without keyboard or mouse input before a presenceChange event is dispatched.
Shell
  menu : NativeMenu
The application menu.
Shell
  openedWindows : Array
[read-only] Lists the NativeWindows that are currently opened by the application.
Shell
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  publisherID : String
[read-only] The publisher ID of this application.
Shell
  runtimePatchLevel : uint
[read-only] The patch level of the AIR runtime.
Shell
  runtimeVersion : String
[read-only] The version number of the AIR runtime.
Shell
  shell : Shell
[static] [read-only] Obtains the singleton instance of the Shell class.
Shell
  startApplicationAtLogin : Boolean
Specifies whether this application will automatically launch whenever the current user logs in.
Shell
  supportsDockIcon : Boolean
[static] [read-only] Specifies whether AIR supports application dock icons on the current operating system.
Shell
  supportsMenu : Boolean
[static] [read-only] Specifies whether the current operating system supports a global application menu bar.
Shell
  supportsSystemTrayIcon : Boolean
[static] [read-only] Specifies whether AIR supports system tray icons on the current operating system.
Shell
  timeSinceLastUserInput : int
[read-only] Returns the time, in seconds, since the last mouse or keyboard input.
Shell
Métodos Públicos
 MétodoDefinido por
  
Activates this application.
Shell
  
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.
Shell
  
Invokes an internal delete command on the focused display object
Shell
  
Invokes an internal copy command on the focused display object
Shell
  
Invokes an internal cut command on the focused display object
Shell
  
Dispatches an event into the event flow.
Shell
  
exit(errorCode:int = 0):void
Terminates this application.
Shell
  
Gets the default application for opening files with the specified extension.
Shell
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
Specifies whether this application is currently the default application for opening files with the specified extension.
Shell
  
Invokes an internal paste command on the focused display object
Shell
  
Invokes platform-specific key equivalent for a keyboard event Used to execute cut/copy/paste/etc editing commands
Shell
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
Invokes an internal redo command on the focused display object
Shell
  
Removes this application as the default for opening files with the specified extension.
Shell
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Shell
  
Invokes an internal selectAll command on the focused display object
Shell
  
Sets this application as the default application for opening files with the specified extension.
Shell
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
  
Invokes an internal undo command on the focused display object
Shell
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Eventos
 Evento Descrição Definido por
   Dispatched when this application becomes the active desktop application.Shell
   Dispatched when the desktop focus is switched to a different application.Shell
   Dispatched when the application's exit sequence is started.Shell
   Dispatched when an application is invoked.Shell
   Dispatched when either a new network connection becomes available or an existing network connection is lost.Shell
   Dispatched when the user has been idle for the period of time specified by the idleThreshold property.Shell
   Dispatched when the user uses the mouse use or keyboard after an idle period.Shell
Detalhes da propriedade
activeWindowpropriedade
activeWindow:NativeWindow  [read-only]

Returns the application window that is currently active. If the active desktop window does not belong to this application, activeWindow returns null.


Implementação
    public function get activeWindow():NativeWindow
applicationDescriptorpropriedade 
applicationDescriptor:XML  [read-only]

The contents of the application descriptor file for this AIR application. The application descriptor file includes application settings.


Implementação
    public function get applicationDescriptor():XML

Exemplo

The following exemplo detects the appId and appId attributes and the name property in the application descriptor file.
var appXml:XML = Shell.shell.applicationDescriptor;
var appId:String = appXml.@appId;
var appVersion:String = appXml.@version;
var appName:String = appXml.name[0];
trace("appId:", appId);
trace("version:", appVersion);
trace("name:", appName);
applicationIDpropriedade 
applicationID:String  [read-only]

The application ID of this application.

The value of this ID is set in the application descriptor file.


Implementação
    public function get applicationID():String
autoExitpropriedade 
autoExit:Boolean  [read-write]

Specifies whether the application should automatically terminate when all windows have been closed.

When autoExit is true, which is the default, the application will terminate when all windows have been closed. Both exiting and exit events will be dispatched. When autoExit is false, you must call Shell.shell.exit() to terminate the application.


Implementação
    public function get autoExit():Boolean
    public function set autoExit(value:Boolean):void
iconpropriedade 
icon:InteractiveIcon  [read-only]

The application icon.

Use Shell.supportsDockIcon and Shell.supportsSystemTrayIcon to determine the icon object type. The type will be one of the subclasses of InteractiveIcon. On Mac OS X, Shell.icon will be an object of type DockIcon. On Windows, Shell.icon will be an object of type SystemTrayIcon.

The icon object is automatically created, but is not initialized with image data. On some operating systems, such as Mac OS X, a default image is supplied, on others, such as Windows, the icon is not displayed unless image data is assigned to the icon. To assign an icon image, set the icon.bitmaps property with an array containing at least one BitmapData object. If more than one BitmapData object is included in the array, then the operating system will choose the image closest in size to the icon's display dimensions, scaling the image if necessary.


Implementação
    public function get icon():InteractiveIcon

Veja também

idleThresholdpropriedade 
idleThreshold:int  [read-write]

Specifies how many seconds must elapse without keyboard or mouse input before a presenceChange event is dispatched.

By default, the idleThreshold is 300 seconds (5 minutes).


Implementação
    public function get idleThreshold():int
    public function set idleThreshold(value:int):void

Veja também

menupropriedade 
menu:NativeMenu  [read-write]

The application menu.

To provide a menu for an application, create a NativeMenu object, along with associated NativeMenuItems and event handlers, and assign it to this menu property.

Application menus are supported when Shell.shell.supportsMenu is true. Not all operating systems support application menus. For exemplo, application menus are supported on Mac OS X, but not on Windows. Assigning a NativeMenu object to this property when Shell.shell.supportsMenu is false is allowed, but does nothing.

Note: On Mac OS X, the menu property references the operating-system-supplied default application menu. You can modify the the existing menu structure by adding and removing items, submenus, and by adding event listeners.


Implementação
    public function get menu():NativeMenu
    public function set menu(value:NativeMenu):void

Veja também

openedWindowspropriedade 
openedWindows:Array  [read-only]

Lists the NativeWindows that are currently opened by the application.


Implementação
    public function get openedWindows():Array
publisherIDpropriedade 
publisherID:String  [read-only]

The publisher ID of this application.

The value of this ID is set in the application's publisherid file, which is generated at install time from the certificate chain used to sign the application.


Implementação
    public function get publisherID():String
runtimePatchLevelpropriedade 
runtimePatchLevel:uint  [read-only]

The patch level of the AIR runtime.


Implementação
    public function get runtimePatchLevel():uint
runtimeVersionpropriedade 
runtimeVersion:String  [read-only]

The version number of the AIR runtime.


Implementação
    public function get runtimeVersion():String
shellpropriedade 
shell:Shell  [read-only]

Obtains the singleton instance of the Shell class.


Implementação
    public static function get shell():Shell

Throws
Error — if accessed by content outside the application security sandbox.
startApplicationAtLoginpropriedade 
startApplicationAtLogin:Boolean  [read-write]

Specifies whether this application will automatically launch whenever the current user logs in.


Implementação
    public function get startApplicationAtLogin():Boolean
    public function set startApplicationAtLogin(value:Boolean):void

Throws
Error — "item exists" on Windows, if set to true when another application with the same name (but with a different path to the executable) is already set to launch when this user logs in.
 
Error — "application not installed" if this application is not installed, which may be the case when launched by the AIR Debug Launcher (ADL).
supportsDockIconpropriedade 
supportsDockIcon:Boolean  [read-only]

Specifies whether AIR supports application dock icons on the current operating system. When true, the Shell.icon property will be of type, DockIcon.

Mac OS X and various Linux user interfaces provide an application "dock" containing icons for running or frequently used applications.


Implementação
    public static function get supportsDockIcon():Boolean

Veja também

supportsMenupropriedade 
supportsMenu:Boolean  [read-only]

Specifies whether the current operating system supports a global application menu bar.

When true, the Shell.menu property can be used to define (or access) a native application menu.


Implementação
    public static function get supportsMenu():Boolean

Veja também

supportsSystemTrayIconpropriedade 
supportsSystemTrayIcon:Boolean  [read-only]

Specifies whether AIR supports system tray icons on the current operating system. When true, the Shell.icon property will be of type, SystemTrayIcon.

On Microsoft Windows, the system tray region of the task bar is officially called the Notification Area.


Implementação
    public static function get supportsSystemTrayIcon():Boolean

Veja também

timeSinceLastUserInputpropriedade 
timeSinceLastUserInput:int  [read-only]

Returns the time, in seconds, since the last mouse or keyboard input.


Implementação
    public function get timeSinceLastUserInput():int

Veja também

Detalhes do método
activateApplication()método
public function activateApplication():void

Activates this application.

Under circumstances determined by the operating system, this method will 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 this application is activated, then one of the visible windows owned by the application will be activated and brought to the desktop foreground, that is, in front of the windows of other applications that may be open.

activateApplication() has no effect if the application has no visible windows.

addEventListener()método 
public override function 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. You can register event listeners on all nodes in the display list for a specific type of event, phase, and priority.

After you successfully register an event listener, you cannot change its priority through additional calls to addEventListener(). To change a listener's priority, you must first call removeListener(). Then you can register the listener again with the new priority level.

Keep in mind that after the listener is registered, subsequent calls to addEventListener() with a different type or useCapture value result in the creation of a separate listener registration. For exemplo, if you first register a listener with useCapture set to true, it listens only during the capture phase. If you call addEventListener() again using the same listener object, but with useCapture set to false, you have two separate listeners: one that listens during the capture phase and another that listens during the target and bubbling phases.

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 removeEventListener(), or memory problems could result. Objects with registered event listeners are not automatically removed from memory because the garbage collector does not remove objects that still have references.

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).

Parâmetros

type:String — The type of event.
 
listener:Function — The listener function that processes the event. This function must accept an Event object as its only parameter and must return nothing, as this exemplo shows:
function(evt:Event):void

The function can have any name.

 
useCapture:Boolean (default = false)Determines whether the listener works in the capture phase or the target and bubbling phases. If useCapture is set to true, the listener processes the event only during the capture phase and not in the target or bubbling phase. If useCapture is false, the listener processes the event only during the target or bubbling phase. To listen for the event in all three phases, call addEventListener twice, once with the useCapture set to true, then again with useCapture set to false.
 
priority:int (default = 0) — The priority level of the event listener. The priority is designated by a signed 32-bit integer. The higher the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. If two or more listeners share the same priority, they are processed in the order in which they were added. The default priority is 0.
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak. A strong reference (the default) prevents your listener from being garbage-collected. A weak reference does not.

Classe-level member functions are not subject to garbage collection, so you can set useWeakReference to true for class-level member functions without subjecting them to garbage collection. If you set useWeakReference to true for a listener that is a nested inner function, the function will be garbge-collected and no longer persistent. If you create references to the inner function (save it in another variable) then it is not garbage-collected and stays persistent.

clear()método 
public function clear():Boolean

Invokes an internal delete command on the focused display object

Retorna
Boolean
copy()método 
public function copy():Boolean

Invokes an internal copy command on the focused display object

Retorna
Boolean
cut()método 
public function cut():Boolean

Invokes an internal cut command on the focused display object

Retorna
Boolean
dispatchEvent()método 
public override function dispatchEvent(event:Event):Boolean

Dispatches an event into the event flow. The event target is the EventDispatcher object upon which the dispatchEvent() method is called.

Parâmetros

event:Event — The Event object that is dispatched into the event flow. If the event is being redispatched, a clone of the event is created automatically. After an event is dispatched, its target property cannot be changed, so you must create a new copy of the event for redispatching to work.

Retorna
Boolean — A value of true if the event was successfully dispatched. A value of false indicates failure or that preventDefault() was called on the event.
exit()método 
public function exit(errorCode:int = 0):void

Terminates this application.

The call to the exit() method will return; the shutdown sequence does not begin until the currently executing code (such as a current event handler) has completed. Pending asynchronous operations are cancelled and may or may not complete.

Note that an exiting event will not be dispatched. If an exiting event is required by application logic, call Shell.shell.dispatchEvent(), passing in an Event object of type exiting. Likewise, closing and close events will not be not dispatched before application windows are closed. If windows should be notified before your application exits, you can dispatch closing events for each open window. If a window close event is required, call the window's close() method before exiting.

Parâmetros

errorCode:int (default = 0)

getDefaultApplication()método 
public function getDefaultApplication(extension:String):String

Gets the default application for opening files with the specified extension.

Note: This method can only be used with file types listed in the fileTypes statement in the application descriptor. getDefaultApplication() will return the string, "false", for all other file types.

Parâmetros

extension:String

Retorna
String
isSetAsDefaultApplication()método 
public function isSetAsDefaultApplication(extension:String):Boolean

Specifies whether this application is currently the default application for opening files with the specified extension.

Parâmetros

extension:String

Retorna
Boolean
paste()método 
public function paste():Boolean

Invokes an internal paste command on the focused display object

Retorna
Boolean
performKeyEquivalent()método 
public function performKeyEquivalent(ev:KeyboardEvent):Boolean

Invokes platform-specific key equivalent for a keyboard event Used to execute cut/copy/paste/etc editing commands

Parâmetros

ev:KeyboardEvent

Retorna
Boolean
redo()método 
public function redo():Boolean

Invokes an internal redo command on the focused display object

Retorna
Boolean
removeAsDefaultApplication()método 
public function removeAsDefaultApplication(extension:String):Boolean

Removes this application as the default for opening files with the specified extension.

Note: This method can only be used with file types listed in the fileTypes statement in the application descriptor. removeAsDefaultApplication() will return falsefor all other file types.

Parâmetros

extension:String

Retorna
Booleantrue if this application was successfully unassigned as the default opening application. Returns false if the operation was unsuccessful, if the specified file extension is not listed in the application descriptor, and if this application is not the current default opener.
removeEventListener()método 
public override function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Parâmetros

type:String
 
listener:Function
 
useCapture:Boolean (default = false)

selectAll()método 
public function selectAll():Boolean

Invokes an internal selectAll command on the focused display object

Retorna
Boolean
setAsDefaultApplication()método 
public function setAsDefaultApplication(extension:String):Boolean

Sets this application as the default application for opening files with the specified extension.

Note: This method can only be used with file types listed in the fileTypes statement in the application descriptor. setAsDefaultApplication() will return falsefor all other file types.

Parâmetros

extension:String

Retorna
Booleantrue if this application was successfully assigned as the default opening application.
undo()método 
public function undo():Boolean

Invokes an internal undo command on the focused display object

Retorna
Boolean
Detalhes do evento
activate Evento
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.ACTIVATE

Dispatched when this application becomes the active desktop application.

The Event.ACTIVATE constant defines the value of the type property of an activate event object.

Note: This event does not go through a "capture phase" and is dispatched directly to the target, whether the target is on the display list or not.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetAny DisplayObject instance with a listener registered for the ACTIVATE event.
deactivate Evento  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.DEACTIVATE

Dispatched when the desktop focus is switched to a different application.

The Event.DEACTIVATE constant defines the value of the type property of a deactivate event object.

Note: This event does not go through a "capture phase" and is dispatched directly to the target, whether the target is on the display list or not.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetAny DisplayObject instance with a listener registered for the DEACTIVATE event.
exiting Evento  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.EXITING

Dispatched when the application's exit sequence is started.

The exiting event is dispatched when application exit is initiated by the operating system, for exemplo, when a user issues the Cmd-Q key sequence on Mac OS X, or when autoExit=true and the last application window is closed. Canceling this event will prevent the application from exiting.

Note: Calling the Shell.exit() method does not cause an exiting event to be dispatched. Applications that wish to warn components of an impending exit should dispatch the exiting event before calling exit

The Event.EXITING constant defines the value of the type property of a exiting event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelabletrue; canceling this event object stops the exit operation.
currentTargetThe Shell object.
targetThe Shell object.
invoke Evento  
Event Object Type: flash.events.InvokeEvent
InvokeEvent.type property = flash.events.InvokeEvent.INVOKE

Dispatched when an application is invoked. All invoke events are queued until a listener is registered. 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 invoke events appropriately.

The constant defines the value of the type property of an InvokeEvent event object.

The InvokeEvent object has the following properties:

PropertiesValues
argumentsthe array of string arguments passed during this invocation.
currentDirectorya object representing the directory that should be used to resolve any relative paths in the arguments array.
bubblesNo.
cancelablefalse; There is no default behavior to cancel.
currentTargetIndicates the object that is actively processing this InvokeEvent object with an event listener.
targetAlways the object.
networkChange Evento  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.NETWORK_CHANGE

Dispatched when either a new network connection becomes available or an existing network connection is lost.

A networkChange event does not necessarily mean that the host computer has gone online or offline; it may just be transitioning from one type of connection to another. Applications can use this event to help optimize the task of monitoring remote resource availability. The dispatch of a networkChange event is often a good time to verify the availability of any remote resources.

Note: There may be a short delay between a network change and the delivery of this event.

The Event.NETWORK_CHANGE constant defines the value of the type property of a networkChange event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe Shell object.
userIdle Evento  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.USER_IDLE

Dispatched when the user has been idle for the period of time specified by the idleThreshold property. The amount of time that the user has been idle can be determined from the timeSinceLastUserInput property.

The Event.USER_IDLE constant defines the value of the type property of a userIdle event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
targetThe Shell object.

Veja também

userPresent Evento  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.USER_PRESENT

Dispatched when the user uses the mouse use or keyboard after an idle period. The period of time that is considered idle is configurable with the idleThreshold property. The amount of time that the user has been idle can be determined from the timeSinceLastUserInput property.

The Event.USER_PRESENT constant defines the value of the type property of a userPresent event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
targetThe Shell object.

Veja também