Developing Adobe® AIR™ Applications with Adobe® Flash® CS3 Professional

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.

Contents

Reading the application descriptor file

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

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;

You can then access the application descriptor data as an XML (E4X) object, as in the following:

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = appXml.namespace();
var appId = appXml.ns::id[0];
var appVersion = appXml.ns::version[0];
var appName = appXml.ns::filename[0];
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:

trace(NativeApplication.nativeApplication.applicationID);


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

trace(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.

See also

 

Send me an e-mail when comments are added to this page | Comment Report