2011-01-25 66 views
2

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

<!-- 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> --> 

回答

0

你试图读的是所谓的“应用描述符”。

它是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); 

请注意,我的命名空间设置为我使用的一个。您应该确保使用应用程序描述符根目录中定义的名称空间。

祝你好运!

+0

正是我需要的。感谢命名空间的提示,我错过了。 – Murgh 2011-01-25 18:13:11

1

你也可以做如下:

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

因此你不需要硬编码命名空间中的代码。