加载初始内容Adobe air时出现ADL错误

use*_*210 6 air

我是AdobeAir的新手.我通过以下链接开始使用helloworld应用程序.

http://help.adobe.com/en_US/air/build/WS144092a96ffef7cc4c0afd1212601c9a36f-8000.html
Run Code Online (Sandbox Code Playgroud)

我能够成功编译HelloWorld.mxml文件,但我无法通过以下命令adl HelloWorld-app.xml运行该应用程序.加载初始内容时错误消息说..错误.

另外我附加了HelloWorld-app.xml

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://ns.adobe.com/air/application/1.0">
    <id>samples.flex.HelloWorld</id>
    <version>0.1</version>
    <filename>HelloWorld</filename>
    <initialWindow>
        <content>HelloWorld.swf</content>
        <visible>true</visible>
        <systemChrome>none</systemChrome>
        <transparent>true</transparent>
        <width>400</width>
        <height>200</height>
    </initialWindow>
</application>
Run Code Online (Sandbox Code Playgroud)

和HelloWorld.mxml是

<?xml version="1.0" encoding="utf-8"?> 
<s:WindowedApplication xmlns:fx="http://`enter code here`ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" 
                       title="Hello World"> 

    <s:Label text="Hello AIR" horizontalCenter="0" verticalCenter="0"/> 
</s:WindowedApplication>
Run Code Online (Sandbox Code Playgroud)

请帮我.

flo*_*ian 7

根据这篇博客文章,您应该检查HelloWorld-app.xml中的命名空间行是否与您的AIR版本匹配.

例如,使用Flex 4.6发行版附带的mxml/adl工具,似乎是正确的命名空间行

<application xmlns="http://ns.adobe.com/air/application/3.1">
Run Code Online (Sandbox Code Playgroud)

您的mxmlc或amxmlc编译器也不是来自比adl更新的SDK.

例如,您无法在AIR 2.6中运行adl中使用Flex 4.6编译的AIR应用程序,您需要使用Flex 4.5工具.


小智 7

谢谢,您的回答有助于解决我的IntelliJ Idea和最新的FLEX/AIR软件包的问题.为了解决这个错误,我必须为我的模块提供一个修改过的应用程序描述符文件,因为自动生成的文件有这个设置:

<application xmlns="http://ns.adobe.com/air/application/2.0">
Run Code Online (Sandbox Code Playgroud)

这里是创建自定义应用程序描述符文件所需的步骤:

文件 - 项目结构 - 模块 - AIR包 - 自定义模板 - 创建

选择最小的AIR版本(实际上是Flex 4.10,我认为它是AIR 3.8),您的模块将编译并运行没有问题.

在此处查看截图


Jef*_*ard 5

The AIR namespace number found in xmlns is only half the story. That defines the minimum runtime version required to display the content. The other half of the story is what -swf-version was the content compiled with.

If the SWF is compiled with a newer -swf-version than the AIR adl can handle, you'll get the "error while loading initial content" message.

I picked up this table from another answer and added AIR version info (source):

  SWF Version  |  Flash Player Version  |  AIR Version
---------------+------------------------+---------------
        9      |        9.0.115.0       |      N/A
       10      |        10.0, 10.1      |      1.5, 2.0
       11      |        10.2            |      2.6
       12      |        10.3            |      2.7
       13      |        11.0            |      3
       14      |        11.1            |      3.1
       15      |        11.2            |      3.2
       16      |        11.3            |      3.3
       17      |        11.4            |      3.4
       18      |        11.5            |      3.5
       19      |        11.6            |      3.6
       20      |        11.7            |      3.7
       21      |        11.8            |      3.8
       22      |        11.9            |      3.9
       23      |        12              |      4
       24      |        13              |      13
       25      |        14              |      14
       26      |        15              |      15
       27      |        16              |      16
       28      |        17              |      17
       29      |        18              |      18
       30      |        19              |      19
       31      |        20              |      20
       32      |        21              |      21
       33      |        22              |      22
       34      |        23              |      23
       35      |        24              |      24
       36      |        25              |      25
       37      |        26              |      26
       38      |        27              |      27
       39      |        28              |      28
       40      |        29              |      29
       41      |        30              |      30
       42      |        31              |      31
Run Code Online (Sandbox Code Playgroud)

You can determine the -swf-version of a SWF file using the swfdump utility included in the Flex and AIR SDKs.

> swfdump example.swf | grep -i '<swf'
<swf xmlns='http://macromedia/2003/swfx' version='18' framerate='24' size='10000x7500' compressed='false' >
Run Code Online (Sandbox Code Playgroud)

The above SWF is compiled with -swf-version=18 and hence will require AIR 3.5 or newer, and xmlns="http://ns.adobe.com/air/application/3.5"

Also note that newer tools can still target older -swf-versions. So you can build SWFs compatible with older AIR and Flash Players. Just be careful to check the APIs you use in the documentation. Some newer APIs (like BitmapData.drawWithQuality) list a minimum player version requirement under Runtime Versions.