Reading application settings



At runtime, you can get properties of the application descriptor file as well as the publisher ID for an application. These are set in the applicationDescriptor and publisherID properties of the NativeApplication object.

Reading the application descriptor file

You can read the application descriptor file of the currently running application, by getting the applicationDescriptor property of the NativeApplication object, as in the following:

var appXml:XML = air.ativeApplication.nativeApplication.applicationDescriptor;

You can use a DOMParser object to parse the data, as in the following:

var xmlString = air.NativeApplication.nativeApplication.applicationDescriptor; 
var appXml = new DOMParser(); 
var xmlobject = appXml.parseFromString(xmlString, "text/xml"); 
var root = xmlobject.getElementsByTagName('application')[0]; 
var appId = root.getElementsByTagName("id")[0].firstChild.data; 
var appVersion = root.getElementsByTagName("version")[0].firstChild.data; 
var appName = root.getElementsByTagName("filename")[0].firstChild.data; 
air.trace("appId:", appId); 
air.trace("version:", appVersion); 
air.trace("filename:", appName);

For more information, see The application descriptor file structure.

Getting the application and publisher identifiers

The application and publisher ids together uniquely identify an AIR application. You specify the application ID in the <id> element of the application descriptor. The publisher ID is derived from the certificate used to sign the AIR installation package.

The application ID can be read from the NativeApplication object’s id property, as illustrated in the following code:

air.trace(air.NativeApplication.nativeApplication.applicationID);

The publisher ID can be read from the NativeApplication publisherID property:

air.trace(air.NativeApplication.nativeApplication.publisherID);
Note: When an AIR application is run with ADL, it does not have a publisher ID unless one is temporarily assigned using the -pubID flag on the ADL command line.

The publisher ID for an installed application can also be found in the META-INF/AIR/publisherid file within the application install directory.

For more information, see About AIR publisher identifiers.