如何在 AS / MXML 代码中读取 AIR 清单文件

发布于 2024-10-14 09:07:16 字数 1164 浏览 2 评论 0原文

Flash Builder 为每个 AIR 项目生成 AppName-app.xml 描述符。那里有许多设置和值,包括以下内容。是否可以在代码中读取这些内容,而无需在运行时显式加载此 XML(即使如此,我也不知道是否可能)?也许 Loader.info 或类似的?

<!-- The name that is displayed in the AIR application installer. 
         May have multiple values for each language. See samples or xsd schema file. Optional. -->
    <name>ffff</name>

    <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade. 
    Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
    An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . -->
    <versionNumber>1</versionNumber>


    <!-- Description, displayed in the AIR application installer.
         May have multiple values for each language. See samples or xsd schema file. Optional. -->
    <!-- <description></description> -->

    <!-- Copyright information. Optional -->
    <!-- <copyright></copyright> --> 

Flash Builder generated AppName-app.xml descriptor for every AIR project. There are a number of settings, values there, including below. Is it possible to read these in your code without explicitly loading this XML at runtime (even this I don't know if it's possible)? Maybe Loader.info or similar?

<!-- The name that is displayed in the AIR application installer. 
         May have multiple values for each language. See samples or xsd schema file. Optional. -->
    <name>ffff</name>

    <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade. 
    Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
    An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . -->
    <versionNumber>1</versionNumber>


    <!-- Description, displayed in the AIR application installer.
         May have multiple values for each language. See samples or xsd schema file. Optional. -->
    <!-- <description></description> -->

    <!-- Copyright information. Optional -->
    <!-- <copyright></copyright> --> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝對不後悔。 2024-10-21 09:07:17

您还可以执行以下操作:

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = appXml.namespace();
title = appXml.ns::name + " " + appXml.ns::versionNumber;

因此您不需要在代码中对命名空间进行硬编码。

You can also do as follows :

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = appXml.namespace();
title = appXml.ns::name + " " + appXml.ns::versionNumber;

Thus you don't need to hardcode the namespace in your code.

瑕疵 2024-10-21 09:07:17

您尝试读取的内容称为“应用程序描述符”。

它是 XML,但很容易阅读:

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;

namespace ns = "http://ns.adobe.com/air/application/2.5";
use namespace ns;

Alert.show("appId: " + appXml.id);
Alert.show("version: " + appXml.versionNumber);
Alert.show("filename: " + appXml.filename);

请注意,我将命名空间设置为我正在使用的命名空间。您应该确保使用应用程序描述符根中定义的命名空间。

祝你好运!

What you are trying to read is called the "Application Descriptor".

It is XML, but it is very easy read:

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;

namespace ns = "http://ns.adobe.com/air/application/2.5";
use namespace ns;

Alert.show("appId: " + appXml.id);
Alert.show("version: " + appXml.versionNumber);
Alert.show("filename: " + appXml.filename);

Notice that I set the namespace to the one I am using. You should make sure you use the namespace defined in the root of your application descriptor.

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文