| Package | air.update |
| Class | public class ApplicationUpdater |
| Inheritance | ApplicationUpdater EventDispatcher Object |
| Runtime Versions: | AIR 1.5, AIR 1.5 |
Managing updates of applications can be complicated. The AIR update framework provides APIs to assist developers in providing good update capabilities in AIR applications. The functionality in that AIR update framework assists developers in the following:
Periodically checking for updates based on an interval or at the request of the user
Downloading AIR files (updates) from a web source
Alerting the user on the first run of the newly installed version
Confirming that the user wants to check for updates
Displaying information on the new update version to the user
Displaying download progress and error information to the user
The AIR update framework lets you store information about the update version of an AIR application in simple XML configuration files. For most applications, setting up these configuration files and including some basic code provides good update functionality to the end user.
Use the AIRUpdater class if you want to define your own user interface for use with the AIR update framework.
See also
| Property | Defined By | ||
|---|---|---|---|
The location of the configuration file that
sets the values for updateURL and delay. | ApplicationUpdater | ||
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | |
[read-only]
The internal state of the updater. | ApplicationUpdater | ||
[read-only]
The current version of the application. | ApplicationUpdater | ||
The interval used for the periodical checker
of the new updates. | ApplicationUpdater | ||
[read-only]
Set to true if this is the first run after a successful update. | ApplicationUpdater | ||
By default, the update framework does a
version comparison in order to detect whether the version from the
remote site is newer than the version of the installed application. | ApplicationUpdater | ||
[read-only]
The application storage directory location. | ApplicationUpdater | ||
[read-only]
The previous version of the application. | ApplicationUpdater | ||
![]() | prototype : Object [static]
A reference to the prototype object of a class or function object. | Object | |
[read-only]
The content of the update descriptor file downloaded
from the update URL. | ApplicationUpdater | ||
The location of the update descriptor file. | ApplicationUpdater | ||
[read-only]
Set to true if there was a postponed update, even if it failed
to install; false otherwise. | ApplicationUpdater | ||
| Method | Defined By | ||
|---|---|---|---|
The constructor function. | ApplicationUpdater | ||
![]() | 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 | |
Cancels the update process. | ApplicationUpdater | ||
Asynchronously downloads and interprets
the update descriptor file. | ApplicationUpdater | ||
Starts the update process on demand. | ApplicationUpdater | ||
![]() |
Dispatches an event into the event flow. | EventDispatcher | |
Asynchronously downloads the update file. | ApplicationUpdater | ||
![]() |
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 | |
Initializes the updater. | ApplicationUpdater | ||
Starts the update process using a local AIR file. | ApplicationUpdater | ||
Installs the update file. | ApplicationUpdater | ||
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() |
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 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 Flash Player gains operating system focus and becomes active. | EventDispatcher | ||
| Dispatched just before installing the update (cancellable) Dispatched just before installing the update, after the installUpdate() method was called. | ApplicationUpdater | |||
| Dispatched just before the update process begins Dispatched just before trying to download the update descriptor file. | ApplicationUpdater | |||
![]() | [broadcast event] Dispatched when Flash Player loses operating system focus and is becoming inactive. | EventDispatcher | ||
| Dispatched when the download of the update file is complete. | ApplicationUpdater | |||
| Dispatched if there is an error during connecting or downloading the update file. | ApplicationUpdater | |||
| Dispatched after a call to the downloadUpdate() method and the connection to the server is established. | ApplicationUpdater | |||
| Dispatched when an error occurred either during initialization or during the update process (if something unexpected happens). | ApplicationUpdater | |||
| Dispatched when an error occurs validating the file passed as the airFile parameter in a call to the installFromAIRFile() method. | ApplicationUpdater | |||
| Dispatched after the updater successfully validates the file in the call to the installFromAIRFile() method. | ApplicationUpdater | |||
| Dispatched after the initialization is complete This event has the following read-only properties: isFirstRun (Boolean) true if this is the first run after a successful update; false otherwise. previousVersion (String) The previous version of the application before the upgrade (set only if isfirstRun is true). | ApplicationUpdater | |||
| Dispatched after the initialization is complete. | ApplicationUpdater | |||
| Dispatched when an error occured while trying to download or parse the update descriptor file. | ApplicationUpdater | |||
| Dispatched after the updater successfully downloads and interprets the update descriptor file. | ApplicationUpdater | |||
| property |
configurationFile:File [read-write] | Runtime Versions: | AIR 1.5 |
The location of the configuration file that
sets the values for updateURL and delay.
If this property points to a non-existent file, calling the initialize() method
results in an Error being thrown.
public function get configurationFile():File public function set configurationFile(value:File):void| property |
currentState:String [read-only] | Runtime Versions: | AIR 1.5 |
The internal state of the updater. The property can be set to the following values:
"Unitialized" The updater has not been initialized.
"Initializing" The updater is initializing.
"Ready" The updater has been initialized
"Before_Checking" The updater has not yet
checked for the update descriptor file.
"Checking" The updater is checking for an
update descriptor file.
"Available" The update descriptor file is
available.
"Downloading" The updater is downloading
the AIR file.
"Downloaded" The updater has downloaded
the AIR file.
"Installing" The updater is installing the
AIR file.
"Pending_Install" The updater has initialized
and there are pending updates.
public function get currentState():String| property |
currentVersion:String [read-only] | Runtime Versions: | AIR 1.5 |
The current version of the application. This property is set during
a call to the initialize() method. It is set to
the version from the application descriptor file.
public function get currentVersion():String| property |
delay:Number [read-write] | Runtime Versions: | AIR 1.5 |
The interval used for the periodical checker of the new updates.
The default value is 0, which indicates that the timer is not active, so no periodical check is done. This can be set either via this property or via the configuration file. When the value is set using both methods, the value set using the property is used.
public function get delay():Number public function set delay(value:Number):void| property |
isFirstRun:Boolean [read-only] | Runtime Versions: | AIR 1.5 |
Set to true if this is the first run after a successful update.
This property is set during the call to the initialize() method.
The developer should check that isFirstRun is set to true if
there is a need to migrate data from one version to another.
public function get isFirstRun():Boolean| property |
isNewerVersionFunction:Function [read-write] | Runtime Versions: | AIR 1.5 |
By default, the update framework does a version comparison in order to detect whether the version from the remote site is newer than the version of the installed application. However, sometimes the default comparison does not match the developer?s versioning scheme. Set this property to set a new function that does the comparison.
The default compare functions will accept versions like x.y.z, where x, y, and z can contain letters and digits.
There are some special conditions that the updater
recognizes. If the test function finds alpha, beta or rc,
the order is alpha < beta < rc.
Example:
appUpdate.isNewerVersionFunction = customFn;
function customFn (currentVersion:String, updateVersion:String):Boolean {// A simple examplereturn updateVersion > currentVersion;} public function get isNewerVersionFunction():Function public function set isNewerVersionFunction(value:Function):void| property |
previousApplicationStorageDirectory:File [read-only] | Runtime Versions: | AIR 1.5 |
The application storage directory location. This property is set during
a call to the initialize() method. Returns the
previous local storage of the application before an upgrade with
a certificate migration; otherwise it is set to null.
public function get previousApplicationStorageDirectory():File| property |
previousVersion:String [read-only] | Runtime Versions: | AIR 1.5 |
The previous version of the application. This property is set during
a call to the initialize() method. Returns the previous version of
the application before the upgrade (set only if isfirstRun is true);
otherwise it is set to null.
public function get previousVersion():String| property |
updateDescriptor:XML [read-only] | Runtime Versions: | AIR 1.5 |
The content of the update descriptor file downloaded
from the update URL. It will return a non-null value only if it
is called after a StatusUpdateEvent.UPDATE_STATUS was
dispatched.
public function get updateDescriptor():XML| property |
updateURL:String [read-write] | Runtime Versions: | AIR 1.5 |
The location of the update descriptor file. Any location valid for a URLRequest path is accepted. This is the only mandatory setting required by the updater. You can set this either via this property or via the configuration file. When the value is set using both methods, the updater uses the value set using the property.
public function get updateURL():String public function set updateURL(value:String):void| property |
wasPendingUpdate:Boolean [read-only] | Runtime Versions: | AIR 1.5 |
Set to true if there was a postponed update, even if it failed
to install; false otherwise.
This property is set during a call to the initialize() method.
Use the wasPendingUpdate and isFirstRun properties
to check if an update failed to install (wasPendingUpdate && !isFirstRun).
public function get wasPendingUpdate():Boolean| () | Constructor |
public function ApplicationUpdater()| Runtime Versions: | AIR 1.5, AIR 1.5 |
The constructor function.
| () | method |
public function cancelUpdate():void| Runtime Versions: | AIR 1.5 |
Cancels the update process. Cancels any pending downloads, deleting any incomplete downloaded files and restarts the periodical check timer.
The update process can be canceled at any time except when the state machine is in "Unitialized" or "Initializing" state. It does nothing when it is called in one of the "Unitialized" or "Initializing" states.
| () | method |
public function checkForUpdate():void| Runtime Versions: | AIR 1.5 |
Asynchronously downloads and interprets
the update descriptor file. Calling this method advances the updater
state to "Checking". Call this method only if the checkForUpdate event
was cancelled.
This method only executes when the updater is in the "Before_Checking" state.
updateStatus | |
updateError |
| () | method |
public function checkNow():void| Runtime Versions: | AIR 1.5 |
Starts the update process on demand. Calling this method does not stop the periodical timer; however it detects that an update process is running and will skip the current iteration.
This method only executes if the current state is "Ready".
This method can result in the updater object dispatching the following event:
checkForUpdate — Dispatched just before the update process begins. |
| () | method |
public function downloadUpdate():void| Runtime Versions: | AIR 1.5 |
Asynchronously downloads the update file. It advances the state machine to "Downloading". It needs to be called only if the StatusUpdateEvent.UPDATE_STATUS event was cancelled when the available property of the event was true.
This method only executes if the current state is "Available". (For information on states, see The update process.)
downloadStart | |
progress | |
downloadError | |
updateEvent |
| () | method |
public function initialize():void| Runtime Versions: | AIR 1.5 |
Initializes the updater. Calling this method does the following:
Initializes the update framework, silently (and synchronously) installing any pending updates. You should call this method during application startup, since it may restart the application.
Checks if there is a postponed update and installs it.
If something went wrong with a prior update, it clears the update file and version information from the storage area.
If the delay expired, it starts the update process; otherwise it starts the periodical timer.
Initialized (defined by UpdateEvent.INITIALIZED The initialization is complete.
Error (defined by ErrorEvent.ERROR) There is an error during initialization.
This method takes no parameters
and returns no value (void).
initialized — The initialization is complete. | |
error: — There is an error during initialization. |
| () | method |
public function installFromAIRFile(file:File):void| Runtime Versions: | AIR 1.5 |
Starts the update process using a local AIR file.
Calling this
method has no effect if an update process is running (if the state
is not "Downloaded").
This function is useful
for an application that has the customUpdateUI element
set to true in the application descriptor file.
Parameters
file:File — The local AIR file to install.
|
fileUpdateStatus | |
updateError |
| () | method |
public function installUpdate():void| Runtime Versions: | AIR 1.5 |
Installs the update file. Calling the method
advances the state machine to "Installing" and needs to be called
only if the downLoadComplete event was cancelled.
Call this method when the updater is in the "Downloaded" state. Calling it in any other state will do nothing.
beforeInstall |
| Event |
air.update.events.UpdateEventair.update.events.UpdateEvent.BEFORE_INSTALL| Runtime Versions: | AIR 1.5 |
Dispatched just before installing the update (cancellable)
Dispatched just before installing the update, after the installUpdate() method
was called. Sometimes, it is useful to prevent the installation
of the update at this time, because the user will lose all current
work as the runtime gets total control of the installation.
Calling this event?s preventDefault() method
postpones the installation until the next restart. Canceling this
and no additional update process can be started (via a call to the
method or because of the periodical check).
The default behavior for ApplicationUpdater library is to download
the update descriptor file. You can call the preventDefault() method
to cancel this behavior.
UpdateEvent.BEFORE_INSTALL constant defines the value of the
type property of the event object for a beforeInstall event.
| Event |
air.update.events.UpdateEventair.update.events.UpdateEvent.CHECK_FOR_UPDATE| Runtime Versions: | AIR 1.5 |
Dispatched just before the update process begins
Dispatched just before trying to download the update descriptor
file. The updater can dispatch this event as a result of directly
calling the checkNow() method or because the periodical
check timer expired.
UpdateEvent.CHECK_FOR_UPDATE constant defines the value of the
type property of the event object for a checkForUpdate event.
| Event |
air.update.events.UpdateEventair.update.events.UpdateEvent.DOWNLOAD_COMPLETE.| Runtime Versions: | AIR 1.5 |
Dispatched when the download of the update file is complete.
Usually this event will be used to show the install update dialog box to ask the user if he wants to install the update.
The default behavior for the the ApplicationUpdater library is
to automatically call the installUpdate() method.
The default behavior can be prevented only when using the ApplicationUpdater
class.
| Event |
air.update.events.DownloadErrorEventair.update.events.DownloadErrorEvent.DOWNLOAD_ERROR| Runtime Versions: | AIR 1.5 |
Dispatched if there is an error during connecting or downloading the update file. It is also dispatched for invalid HTTP statuses (such as 404 - File not found).
When this event is dispatched the periodical timer is automatically restarted (if the delay is greater than 0).
This event has an errorID property. This is
an integer defining additional error information (see the following
table). An additional subErrorID property may contain
more error information.
|
errorID Error code |
Description |
|---|---|
|
16800 |
Occurs during validating the downloaded
update file. The |
|
16801 |
Invalid Adobe AIR file (missing application.xml). |
|
16802 |
Invalid Adobe AIR file (missing mime type). |
|
16807 |
Invalid Adobe AIR file (format). |
|
16804 |
Invalid Adobe AIR file (invalid flags). |
|
16805 |
Invalid Adobe AIR file (unknown compression). |
|
16806 |
Invalid Adobe AIR file (invalid filename). |
|
16807 |
Invalid Adobe AIR file (corrupt). |
|
16808 |
Configuration file does not exist. |
|
16809 |
The |
|
16810 |
Reserved. |
|
16811 |
Invalid configuration file (unknown configuration version). |
|
16812 |
Invalid configuration file (URL missing). |
|
16813 |
Invalid configuration file (delay format). |
|
16814 |
Invalid configuration file (invalid defaultUI values). |
|
16815 |
Invalid update descriptor (unknown descriptor version). |
|
16816 |
Invalid update descriptor (missing update version). |
|
16817 |
Invalid update descriptor (invalid description). |
|
16818 |
IO error while saving data to disk. The |
|
16819 |
Security error while downloading. The |
|
16820 |
Invalid HTTP status code. The |
|
16821 |
Reserved. |
|
16822 |
I/O error while downloading. The |
|
16823 |
End-of-file error while saving data to disk.
The |
|
16824 |
Invalid update descriptor. The |
|
16825 |
The update file contains an application with a different application ID. |
|
16826 |
The update file does not contain a newer version of the application. |
|
16827 |
The version contained in the update file does not match the version from the update descriptor. |
|
16828 |
Cannot update application, usually because the application is running in the AIR Debug Launcher (ADL). |
|
16829 |
Missing update file at install time. |
DownloadErrorEvent.DOWNLOAD_ERROR constant defines the value of the
type property of the event object for a downloadError event.
| Event |
air.update.events.UpdateEventair.update.events.UpdateEvent.DOWNLOAD_START| Runtime Versions: | AIR 1.5 |
Dispatched after a call to the downloadUpdate() method
and the connection to the server is established. When using ApplicationUpdater
library, you may want the event handler for this event to display
a progress bar to report the download progress to the user.
UpdateEvent.DOWNLOAD_START constant defines the value of the
type property of the event object for a downloadStart event.
| Event |
flash.events.ErrorEventflash.events.ErrorEvent.ERROR| Runtime Versions: | AIR 1.5 |
Dispatched when an error occurred either during initialization or during the update process (if something unexpected happens).
Defines the value of thetype property of an error event object.
This event has the following properties:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object experiencing a network operation failure. |
text | Text to be displayed as an error message. |
| Event |
air.update.events.StatusFileUpdateErrorEventair.update.events.StatusFileUpdateErrorEvent.FILE_UPDATE_ERROR| Runtime Versions: | AIR 1.5 |
Dispatched when an error occurs validating the file passed
as the airFile parameter in a call to the installFromAIRFile() method.
StatusUpdateErrorEvent.UPDATE_ERROR constant defines the value of the
type property of the event object for a statusUpdateError event.
| Event |
air.update.events.StatusFileUpdateEventair.update.events.StatusFileUpdateEvent.FILE_UPDATE_STATUS| Runtime Versions: | AIR 1.5 |
Dispatched after the updater successfully validates the
file in the call to the installFromAIRFile() method.
The default behavior is to install the update if the available of the available property of the StatusFileUpdateEvent object is set to true. The default behavior can be prevented only when using the ApplicationUpdater class.
This event has the following properties:
available (Boolean) true if there is
a different version available than one of the current application,
false otherwise (same version)
version (String) The new available version.
path (String) The nativePath property of
the update File object specified by the airFile parameter
in a call to the installFromAIRFile() method.
StatusUpdateEvent.UPDATE_STATUS constant defines the value of the
type property of the event object for a updateStatus event.
| Event |
air.update.events.UpdateEventair.update.events.UpdateEvent.INITIALIZED| Runtime Versions: | AIR 1.5 |
Dispatched after the initialization is complete
This event has the following read-only properties:
isFirstRun (Boolean) true if
this is the first run after a successful update; false otherwise.
previousVersion (String) The previous version
of the application before the upgrade (set only if isfirstRun is true).
currentVersion (String) The version from
the application descriptor file of the currently installed version.
UpdateEvent.INITIALIZED constant defines the value of the
type property of the event object for a initialized event.
| Event |
flash.events.ProgressEventflash.events.ProgressEvent.PROGRESS| Runtime Versions: | AIR 1.5 |
Dispatched after the initialization is complete.
Defines the value of thetype property of a progress event object.
This event has the following properties:
| Property | Value |
|---|---|
bubbles | false |
bytesLoaded | The number of items or bytes loaded at the time the listener processes the event. |
bytesTotal | The total number of items or bytes that ultimately will be loaded if the loading process succeeds. |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object reporting progress. |
| Event |
air.update.events.StatusUpdateErrorEventair.update.events.StatusUpdateErrorEvent.UPDATE_ERROR| Runtime Versions: | AIR 1.5 |
Dispatched when an error occured while trying to download or parse the update descriptor file.
When the updater dispatches this event, the periodical timer
is automatically restarted (if the delay setting is greater than
0). The application should consider hiding any error dialog boxes
when the updater dispatches a new checkForUpdate event.
StatusUpdateErrorEvent.UPDATE_ERROR constant defines the value of the
type property of the event object for a statusUpdateError event.
| Event |
air.update.events.StatusUpdateEventair.update.events.StatusUpdateEvent.UPDATE_STATUS| Runtime Versions: | AIR 1.5 |
Dispatched after the updater successfully downloads and interprets the update descriptor file.
The default behavior is to start downloading the update if the
available of the available property of the StatusUpdateEvent object
is set to true. The default behavior can be prevented
only when using the ApplicationUpdater class.
This event has the following properties:
available (Boolean) true if
the update descriptor file specifies a version that is different
than that of the current application; false otherwise
(the version is the same).
version (String) The string representing
the new available version.
details (Array) An array defining the details string
for each of the supported languages. If there is no localized description,
this is defined as an array in which the first element is an empty
string ("") and the second element is the details
string. When there are localized descriptions, each element in the
array is an array itself with two elements. The first element is
the locale code, and the second is the description. For example,
the following array has sub-arrays for two languages (U.S. English
and French): ["en-US", "Hello World"], ["fr", "Bonjour monde"].
The languages are listed in the same order as in the update descriptor.
StatusUpdateEvent.UPDATE_STATUS constant defines the value of the
type property of the event object for a updateStatus event.