How can I read the version from the application descriptor file

So, I have a base application descriptor file for my AIR application. It looks something like this, short for sanity:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/2.0">
  <version>1.0.10</version>
</application>

Now I want the version to be displayed in the application, but I do not want it to support the version in several places, so how can I read this version number from the application?

+3
source share
2 answers

Check out the following code:

            var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
            var ns:Namespace = appXml.namespace(); 
            trace(appXml.ns::version); 
+5
source

In recent versions of AIR (AIR version 3.x), this has changed a bit. Instead of appXml.ns :: version, you should use appXml.ns :: versionNumber instead.

: appXml.ns:: versionNumber - XMLList, XML, String :

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = appXml.namespace();
var appVersion:String = appXml.ns::versionNumber[0].toString();
trace("appVersion", appVersion);

, 17 2017 .: - AIR applicationDescriptor. AIR 23:

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:String = appXml.namespace().toString();
var nsArray:Array = ns.split("/");
var appVersion:Number = nsArray[nsArray.length - 1];
trace("appVersion:", appVersion); // appVersion: 23.0
+6

Source: https://habr.com/ru/post/1759382/


All Articles