使用 MXMLC 编译 Flex 应用程序时包含配置文件
我正在使用: - Flex SDK 3.5.0 - 欧芹 2.2.2。 - Flash Builder 4
在我的 src 文件夹中(配置为 Flash Builder 中源路径的一部分),我有一个通过 Parsley 配置的logging.xml:
FlexLoggingXmlSupport.initialize();
XmlContextBuilder.build("com/company/product/util/log/logging.xml");
当我通过 Flash Builder 运行我的应用程序时,XmlContentBuilder 似乎找到logging.xml(实现是常规的URLLoader)。
当我使用 MXMLC(无论是在 Ant 还是命令行中)编译应用程序,然后运行 swf 时,出现以下错误:
Cause(0): 加载 com/company/product/util/log/logging.xml 时出错: URLLoader 中的错误 - 原因:错误 #2032:流错误。 URL:file:///C|/workspace/folder01/product/target/com/company/product/util/log/logging.xml - 原因:错误 #2032:流错误。 URL: file:///C|/workspace/folder01/product/target/com/company/product/util/log/logging.xml
这是 Ant 中的 MXMLC 标记:
<mxmlc file="${product.src.dir}/com/company/product/view/Main.mxml" output="${product.target.dir}/${product.release.filename}" keep-generated-actionscript="false">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<!-- source paths -->
<source-path path-element="${FLEX_HOME}/frameworks" />
<compiler.source-path path-element="${product.src.dir}" />
<compiler.source-path path-element="${product.locale.dir}/{locale}" />
<compiler.library-path dir="${product.basedir}" append="true">
<include name="libs" />
</compiler.library-path>
<warnings>false</warnings>
<debug>false</debug>
</mxmlc>
这是命令行:
\mxmlc.exe -output "C:\temp\Rap.swf" -load-config "C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks\3.5.0\frameworks\flex-config.xml" -source-path "C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks\3.5.0\frameworks" C:\workspace\folder01\product\src C:\workspace\folder01\product\locale\en_US -library-path+=C:\workspace\folder01\product\libs -file-specs C:\workspace\folder01\product\src\com\company\product\view\main.mxml
现在也许我不知道没有正确理解这一点,但据我了解,SWF 应该使用我提供 MXMLC 作为源路径的路径中的所有资源进行编译。由于某种原因,XML 文件似乎未编译到 SWF 中,因此未成功找到 XmlContentBuilder 的相对路径。
我找不到任何可以为 MXMLC 提供解决此问题的参数。
我尝试将 -dump-config 选项与 Flash Builder 的编译器一起使用,然后将该配置提供给 MXMLC,但它也不起作用。
我尝试为 XmlContentBuilder 提供绝对路径。当我通过 Ant 使用 MXMLC 进行编译时,效果很好,但当我在命令行中使用 MXMLC 时,它仍然不起作用...
我很高兴在这里得到启发,关于所有主题 - 使用 MXMLC、使用相对值访问资源路径,配置欧芹日志记录等。
提前非常感谢, 丹尼尔
I'm using:
- Flex SDK 3.5.0
- Parsley 2.2.2.
- Flash Builder 4
Down in my src folder (which is configured as part of the source path in the Flash Builder), I have a logging.xml which I configure via Parsley:
FlexLoggingXmlSupport.initialize();
XmlContextBuilder.build("com/company/product/util/log/logging.xml");
When I run my application through Flash Builder, the XmlContentBuilder seems to locate the logging.xml (the implementation is a regular URLLoader one).
When I compile my application using MXMLC (whether in Ant or command-line), and then run the swf, I get the following error:
Cause(0): Error loading com/company/product/util/log/logging.xml: Error in URLLoader - cause: Error #2032: Stream Error. URL: file:///C|/workspace/folder01/product/target/com/company/product/util/log/logging.xml - cause: Error #2032: Stream Error. URL: file:///C|/workspace/folder01/product/target/com/company/product/util/log/logging.xml
Here is the MXMLC tag in Ant:
<mxmlc file="${product.src.dir}/com/company/product/view/Main.mxml" output="${product.target.dir}/${product.release.filename}" keep-generated-actionscript="false">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<!-- source paths -->
<source-path path-element="${FLEX_HOME}/frameworks" />
<compiler.source-path path-element="${product.src.dir}" />
<compiler.source-path path-element="${product.locale.dir}/{locale}" />
<compiler.library-path dir="${product.basedir}" append="true">
<include name="libs" />
</compiler.library-path>
<warnings>false</warnings>
<debug>false</debug>
</mxmlc>
And here is the command line:
\mxmlc.exe -output "C:\temp\Rap.swf" -load-config "C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks\3.5.0\frameworks\flex-config.xml" -source-path "C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks\3.5.0\frameworks" C:\workspace\folder01\product\src C:\workspace\folder01\product\locale\en_US -library-path+=C:\workspace\folder01\product\libs -file-specs C:\workspace\folder01\product\src\com\company\product\view\main.mxml
Now perhaps I don't get this correctly, but as far as I understand the SWF should be compiled with all of the resources in the paths I give MXMLC as source-paths. For some reason it seems that the XML file is not compiled into the SWF, hence the relative path of the XmlContentBuilder isn't located successfully.
I could not find any argument to provide the MXMLC with that might solve this.
I tried using the -dump-config option with the Flash Builder's compiler, then giving that configuration to MXMLC, but it didn't work either.
I tried providing the XmlContentBuilder with an absolute path. That worked fine when I compiled with MXMLC via Ant, but still didn't work when I used MXMLC in the command-line...
I'd be happy to be enlightened here, regarding all subjects - using MXMLC, accessing resources with relative paths, configuring logging in Parsley, etc.
Many thanks in advance,
Daniel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,直到现在我才明白发生了什么:
XmlContextBuilder 内的 URLLoader 尝试在本地访问文件 (file://)。
Flash builder 将文件从其原始位置(“src”文件夹)复制到目标位置(“bin-debug”文件夹),然后 URLLoader 找到该文件。
当我编译 SWF 时,我没有将文件复制到目标位置(错误消息中所示的“目标”文件夹)。这就是为什么没有找到它...
现在,我想我需要更好地了解如何正确访问 XML 文件...
Well, only now I've ccme to understand what's going on:
The URLLoader inside the XmlContextBuilder tried to access the file locally (file://).
Flash builder copied the file from its original location (the 'src' folder) to the target location (the 'bin-debug' folder), and then it was found by the URLLoader.
When I compiled the SWF, I didn't copy the file to my target location (the 'target' folder as seen in the error message). That's why it wasn't found...
Now, I guess I need a better understanding of how to properly access an XML file...