简体   繁体   English

仅使用actionScript在flex中获取并设置应用程序的版本号

[英]Get and set application's version number in flex using actionScript alone

Here we want to display Flex Project's version number in an "About Us" screen's label. 在这里,我们希望在“关于我们”屏幕的标签中显示Flex Project的版本号。

I want to retrieve the build number and last compiled time stamp dynamically. 我想动态检索内部版本号和上次编译的时间戳。

I have surfed in net and found in many examples that use ruby or bat coding to do the process of updating a version number and retrieving. 我在网上浏览过并发现许多使用ruby或bat编码的例子来进行更新版本号和检索的过程。 Is there any way to update and maintain the version number dynamically(each time I start the debugger) using actionscript alone (with out using any other language's coding). 有没有办法动态更新和维护版本号(每次我启动调试器) 单独使用actionscript (不使用任何其他语言的编码)。

kindly help me. 请帮助我。 Thanks a lot in advance. 非常感谢提前。

You can read your App's descriptor at run-time (for example to get the app's version number) like this: 您可以在运行时读取应用程序的描述符(例如,获取应用程序的版本号),如下所示:

private function getAppVersion():String {
    var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
    var ns:Namespace = appXml.namespace();
    var appVersion:String = appXml.ns::versionNumber[0];
    return appVersion;
}

This blog mantions it: http://inflagrantedelicto.memoryspiral.com/2009/02/quick-tip-display-application-version-in-your-air-app/ 这个博客提到它: http ://inflagrantedelicto.memoryspiral.com/2009/02/quick-tip-display-application-version-in-your-air-app/

The Flex version number is available, but it's namespaced. Flex版本号可用,但它是命名空间。 You'll have to use the namespace mx_internal to be able to access it. 您必须使用命名空间mx_internal才能访问它。 Like this: 像这样:

import mx.core.mx_internal;

use namespace mx_internal;

versionLabel.text = VERSION;

Usually you should treat everything Adobe has namespaced 'mx_internal' with care, because they don't guarantee that anything in there will remain the same in future versions of Flex. 通常你应该小心处理Adobe命名空间'mx_internal'的所有内容,因为它们不能保证Flex的未来版本中的任何内容都保持不变。 So you might run into backwards compatibility issues when upgrading your Flex SDK. 因此,升级Flex SDK时可能会遇到向后兼容性问题。 It seems rather unlikely they would make changes to the VERSION constant though. 他们似乎不太可能会对VERSION常数进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM