Using InvokeEvent.reason in AIR 1.5.1

AIR 1.5.1, released today, is not quite a typical dot release containing just bug fixes. It also contains one minor—albeit useful—new feature.

Applications can already detect when they’ve been invoked by listening for the InvokeEvent that is dispatched by NativeApplication. This is dispatched when they’re started from the command line, via the GUI, or by opening an associated file.

Applications can also register to be launched automatically during user login. However, prior to 1.5.1, there was no reliable way to distinguish this login case from the the other reasons an application might be started. That turns out to be awkward: In the login case, applications often want to avoid opening new windows. In all other cases, they generally want to make sure they do open a new window.

Starting with AIR 1.5.1, the InvokeEvent class contains a new property, “reason”, that distinguishes between these two cases. It has two possible values: “standard” and “login”. These are, I hope, self-explanatory.

Note that in order to use this new API, you must update your application to use the AIR 1.5.1 namespace by changing its descriptor. (There are no other changes to the descriptor schema in this release.) The new descriptor will trigger an auto-update to AIR 1.5.1 should someone attempt to install your application against an older version, thus guaranteeing that the new API will actually be available.