Packagecom.distriqt.extension.application.events
Classpublic class ApplicationStateEvent
InheritanceApplicationStateEvent Inheritance flash.events.Event

This event is used to dispatch application state event changes, such as application deactivations, and background / foreground events.

BACKGROUND and FOREGROUND events are very useful in situations where you aren't interested in the loss of focus of your AIR stage but that the entire application has been moved to the background (or foreground).

The difference here is obvious when your application launches native activities or displays dialogs, or even in response to the iOS control centre overlay. In these situations the normal AIR DEACTIVATE event will fire even though your AIR application is still running in the foreground.

It is useful to be able to determine the difference between these cases and this is the intent of these events.

Update April 2017: Apple has made the determining of the reason for deactivate/background event (lock or home) unsupported and will now lead to AppStore rejection. Hence this functionality is no longer available on iOS. iOS will continue to dispatch the deactivate event however will always report the home button was pressed.



Public Properties
 PropertyDefined By
  code : String
The code associated with this event, see the CODE prefixed options in this class.
ApplicationStateEvent
  description : String
Unused
ApplicationStateEvent
Public Methods
 MethodDefined By
  
ApplicationStateEvent(type:String, code:String, description:String, bubbles:Boolean = false, cancelable:Boolean = false)
Constructor
ApplicationStateEvent
  
clone():Event
[override]
ApplicationStateEvent
Public Constants
 ConstantDefined By
  ACTIVATE : String = applicationstate:activate
[static] Similar to the standard AIR Event.ACTIVATE event.
ApplicationStateEvent
  BACKGROUND : String = applicationstate:background
[static] This event is dispatched when your application enters the background rather than a deactivated state.
ApplicationStateEvent
  CODE_HOME : String = deactivate:home
[static] This code occurs when a normal application deactivation occurs, by pressing the home button or by switching between applications.
ApplicationStateEvent
  CODE_LOCK : String = deactivate:lock
[static] This code occurs when the phone screen is disabled and the phone enters it's 'lock' power saving state .
ApplicationStateEvent
  DEACTIVATE : String = applicationstate:deactivate
[static] Dispatched when the application is deactivated.
ApplicationStateEvent
  FOREGROUND : String = applicationstate:foreground
[static] This event is dispatched when your application returns from a background state and enters the foreground This has the advantage over the ACTIVATE event that it isn't dispatched when your AIR stage gains focus after a dialog or other activity was closed.
ApplicationStateEvent
Property Detail
codeproperty
public var code:String

The code associated with this event, see the CODE prefixed options in this class.

This value is currently invalid on iOS due to Apple policy changes

See also

descriptionproperty 
public var description:String

Unused

Constructor Detail
ApplicationStateEvent()Constructor
public function ApplicationStateEvent(type:String, code:String, description:String, bubbles:Boolean = false, cancelable:Boolean = false)

Constructor

Parameters
type:String
 
code:String
 
description:String
 
bubbles:Boolean (default = false)
 
cancelable:Boolean (default = false)
Method Detail
clone()method
override public function clone():Event

Returns
Event
Constant Detail
ACTIVATEConstant
public static const ACTIVATE:String = applicationstate:activate

Similar to the standard AIR Event.ACTIVATE event.

BACKGROUNDConstant 
public static const BACKGROUND:String = applicationstate:background

This event is dispatched when your application enters the background rather than a deactivated state.

This has the advantage over the DEACTIVATE event (including the normal AIR Event) that it isn't dispatched when a dialog or another activity is launched from your application, where the AIR stage may lose focus but your application is still in the foreground.

CODE_HOMEConstant 
public static const CODE_HOME:String = deactivate:home

This code occurs when a normal application deactivation occurs, by pressing the home button or by switching between applications.

CODE_LOCKConstant 
public static const CODE_LOCK:String = deactivate:lock

This code occurs when the phone screen is disabled and the phone enters it's 'lock' power saving state . This is either from a screen time out or by the user pressing the power button.

DEACTIVATEConstant 
public static const DEACTIVATE:String = applicationstate:deactivate

Dispatched when the application is deactivated. This is an alternative of the AIR Event.DEACTIVATE which will contain more information about whether the application screen was turned off in the deactivation process.

FOREGROUNDConstant 
public static const FOREGROUND:String = applicationstate:foreground

This event is dispatched when your application returns from a background state and enters the foreground

This has the advantage over the ACTIVATE event that it isn't dispatched when your AIR stage gains focus after a dialog or other activity was closed. Instead it is only dispatched if your application was minimised and is now returning to the foreground.