Is there an as3 API in Air (I'm using 3.2) to access my application version ? The one I give on the App Store or Android Market ?
Yeah you can pull it directly from the application xml descriptor. Something like this should work:
var descriptor:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = descriptor.namespace();
var version:String = descriptor.ns::version[0];
Looks like it's different for Air 4.0 This worked for me:
var descriptor:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = descriptor.namespace();
var version:String = descriptor.ns::versionNumber;
var _descriptor:XML = nativeApplication.applicationDescriptor;
var ns:Namespace = _descriptor.namespace();
var version:String = _descriptor.ns::versionNumber;
This is what works for me. "descriptor" var is used in AIR 3.2 for a UIComponentDescriptor, so I couldn't use that variable name. Also, statically accessing nativeApplication (NativeApplication.nativeApplication) gave me a null pointer reference, so I just grabbed it directly.
Lastly, versionNumber is what stores the version in AIR 3.2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With