3

我正在构建一个 Flex 4 应用程序(使用 flexmojos 而不是 FlexBuilder)。如果我使用 mx:Application 如下创建一个测试应用程序,那么我会看到一个我期望的按钮:

<mx:Application
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="http://www.adobe.com/2006/mxml">

    <s:Button
        label="Button"/>

</mx:Application>

但是,如果我使用 s:Application 那么我看到的只是一个空白(白色)屏幕:

<s:Application
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="http://www.adobe.com/2006/mxml">

    <s:Button
        label="Button"/>

</s:Application>

顺便说一句,我目前没有使用 html 包装器,我只是直接在浏览器中加载 swf。

这是我的pom...

<project 
    xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.aaa.bbb</groupId>
    <artifactId>app</artifactId>
    <packaging>war</packaging>
    <version>2.0-SNAPSHOT-1</version>
    <name>app</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <sourceDirectory>src/main/flex</sourceDirectory>
        <testSourceDirectory>src/test/flex</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.sonatype.flexmojos</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>3.9</version>
                <dependencies>
                    <dependency>
                        <groupId>com.adobe.flex</groupId>
                        <artifactId>compiler</artifactId>
                        <version>4.5.0.20967</version>
                        <type>pom</type>
                    </dependency>
                </dependencies>
                <extensions>true</extensions>
                <configuration>
                    <policyFileUrls>
                        <url>http://fpdownload.adobe.com/pub/swz/crossdomain.xml</url>
                    </policyFileUrls>
                    <rslUrls>
                        <url>http://fpdownload.adobe.com/pub/{extension}/flex/4.5.0.20967/{artifactId}_{version}.{extension}</url>
                    </rslUrls>
                </configuration>
                <executions>
                    <execution>
                        <id>flex-compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile-swf</goal>
                        </goals>
                        <configuration>
                            <output>src/main/webapp/Main.swf</output>
                        </configuration>                        
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>textLayout</artifactId>
          <version>4.5.0.20967</version>
          <type>swc</type>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>framework</artifactId>
          <version>4.5.0.20967</version>
          <type>swc</type>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>spark</artifactId>
          <version>4.5.0.20967</version>
          <type>swc</type>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>sparkskins</artifactId>
          <version>4.5.0.20967</version>
          <type>swc</type>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>rpc</artifactId>
          <version>4.5.0.20967</version>
          <type>swc</type>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>datavisualization</artifactId>
          <version>4.5.0.17855</version>
          <type>swc</type>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>flex-framework</artifactId>
          <version>4.5.0.20967</version>
          <type>pom</type>
        </dependency>
    </dependencies>

</project>

有人知道我在做什么错吗?谢谢

更新:

我现在将所有 RLS 作为 .swz 文件存储在与 .swf 文件相同的位置,并且我将 RSL URL 设置如下:

                            <configuration>
                    <policyFileUrls>
                        <url>http://fpdownload.adobe.com/pub/swz/crossdomain.xml</url>
                    </policyFileUrls>
                    <rslUrls>
                        <url>{artifactId}_${flex.sdk.version}.{extension}</url>
                    <url>http://fpdownload.adobe.com/pub/{extension}/flex/${flex.sdk.version}/{artifactId}_${flex.sdk.version}.{extension}</url>
                    </rslUrls>
                </configuration>

尽管如此,该应用程序仍然是空白的。使用 FireBug 时,我似乎没有看到任何对任何 RSL 的请求,也没有任何与此相关的错误消息。似乎甚至没有尝试加载 RSL。

这很奇怪!

4

7 回答 7

5

如果您使用的是 mojos < 4,请将其添加到您的 flexmojos-maven-plugin 配置中

<configuration>
    <configurationReport>true</configurationReport>
    <sourceFile>Main.mxml</sourceFile>
    <configFiles><!-- Fix for Mojos's < 4 -->
        <configFile>flex-config-swf-version-11.xml</configFile> 
    </configFiles> 
...

然后创建这个文件

<?xml version="1.0"?> 
<flex-config> 
        <swf-version>11</swf-version> 
</flex-config> 

来自:http ://groups.google.com/group/flex-mojos/browse_thread/thread/143f69219fcddc16#

如果您在 4+ 上,您可以将其添加到您的配置中

<configuration>
    <configurationReport>true</configurationReport>
    <sourceFile>Main.mxml</sourceFile>
    <swfVersion>11</swfVersion>
...

来自:http ://groups.google.com/group/flex-mojos/browse_thread/thread/9ff3ea2e0e0461a4

于 2011-07-18T13:10:07.853 回答
1

在使用 ANT 构建 IntelliJ 时,我随机遇到了同样的问题。将目标 Flash 播放器版本更改为 10.2,而不是 10.3 解决了该问题。

于 2011-08-09T19:22:43.447 回答
1

我在使用 Flex Mojos 4.0 和 Flex 4.5 时遇到了同样的问题。当我升级到 Flex Mojos 4.1-BETA 后问题得到解决。

于 2011-12-14T04:23:30.213 回答
0

我想问题出在默认情况下应该加载的 RSL 中,但您没有正确定位它们。尝试列出所有必需的 RSL 并将其范围更改为merged. 我认为这个这个链接会很有用。

于 2011-06-21T13:10:28.713 回答
0

尝试在这两种情况下将宽度设置为 100,将高度设置为 25。

于 2011-06-21T13:10:51.283 回答
0

这并不完全是一个答案,而是更多可能有助于找到实际答案的故障排除信息。我在 IntellijIdea 10 中使用 make 构建 swf 的结果相同。我使用的是 4.5 SDK。

有人建议我需要 Flash Player 11,它在 Adob​​e 的孵化器中。我在 flash player 11 中得到了相同的结果(使用 spark 时出现白屏,使用 mx 时很好)。

我在其他项目中使用 FlexMojos,但为此我只是在使用 Flex 4.5 进行一些概念验证测试,并且不想在构建方程中引入另一个变量,直到事情稳定下来。

希望这些附加信息将帮助您深入了解问题。

于 2011-07-07T21:15:40.343 回答
0
  1. 首先,要将其用作 rsl,您需要提供范围作为缓存 <scope>caching</scope>。你得到的警告很好,它是 flex-mojos 和 maven 的问题,我记得在flex-mojos-group的帖子中看到它。请搜索你自己:)

  2. 检查文本布局版本,因为它总是带有与其他框架 rsls 不同的数字。即对于文本布局,您需要有一个单独的条目。参考这个

                <rslUrls>
                    <url>{artifactId}_${flex.sdk.version}.{extension}</url>
                   <url>{artifactId}_${flex.textlayout.version}.{extension}</url><url>http://fpdownload.adobe.com/pub/{extension}/flex/${flex.sdk.version}/{artifactId}_${flex.sdk.version}.{extension}</url>
    
  3. rslurls 中的条目数必须与 policyurls tag 中的条目数匹配。请参阅此处。所以 policyFileUrls 策略文件 URL 数组。rslUrls 数组中的每个条目都必须在该数组中有对应的条目

  4. 使用firefox的firebug扩展,观察net控制台看是否在下载rsls。你也可以使用net-export插件保存 netconsole 日志并粘贴。

修改您的代码以执行上述检查并告知结果。

于 2011-08-23T07:59:29.797 回答