Displaying the version number in Adobe AIR
Posted by Daniel | Posted in AIR, Development, Flex, Software | Posted on October 12, 2011
0
In the Adobe AIR application descriptor file there are many options you can set. One of which is the
It can be useful to display your version number inside of your app to inform the user as well as help with bug reports among other reasons. In order to prevent you from having to update the version number in multiple places you can use AS3 to grab it from the application descriptor and update your text for your app on the fly, as it loads. Here is an example of how to do that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import mx.events.FlexEvent; protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void { var appXML:XML = flash.desktop.NativeApplication.nativeApplication.applicationDescriptor; var ns:Namespace = appXML.namespace(); versionLabel.text = 'v' + appXML.ns::versionNumber; } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <s:Label id="versionLabel" /> </s:WindowedApplication> |



