我试图使用ant来构建我的flex项目,但得到一个错误:
Invalid Embed directive in stylesheet - can't resolve source 'Embed(source="/assets/fileNm.jpg")' (File: style.css)
我不知道该怎么办。请帮帮我。
src
assets
css
style.css
img
com
My ANT Task:
<!-- Complie source-->
<target name="compileBLP" depends="copyAssets">
<record name="${LOG_FILE}" action="start" append="false" />
<mxmlc file="${SRC_DIR}/Main.mxml" output="${DEPLOY_DIR}/main.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.debug>false</compiler.debug>
<runtime-shared-library-path
path-element="${FLEX_FRAMEWORK}/framework.swc">
<url rsl-url="framework_4.1.0.16076.swf"/>
<url rsl-url="framework_4.1.0.16076.swz"/>
<url rsl-url="osmf_flex.4.0.0.13495.swf"/>
<url rsl-url="osmf_flex.4.0.0.13495.swz"/>
<url rsl-url="rpc_4.1.0.16076.swf"/>
<url rsl-url="rpc_4.1.0.16076.swz"/>
<url rsl-url="spark_4.1.0.16076.swf"/>
<url rsl-url="spark_4.1.0.16076.swz"/>
<url rsl-url="sparkskins_4.1.0.16076.swf"/>
<url rsl-url="sparkskins_4.1.0.16076.swz"/>
<url rsl-url="textLayout_1.1.0.604.swf"/>
<url rsl-url="textLayout_1.1.0.604.swz"/>
</runtime-shared-library-path>
<compiler.source-path path-element="${SRC_DIR}" />
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
</compiler.library-path>
<compiler.library-path dir="${basedir}" append="true">
<include name="libs" />
</compiler.library-path>
</mxmlc>
<record name="${LOG_FILE}" action="stop"/>
</target>
Flex在相对路径和绝对路径的区别上一直有点模糊,再加上Maven或ANT,问题就更复杂了。从这里我可以告诉你-你在src下有一个assets文件夹,src被列为编译器的源代码路径,但是你的嵌入指令声称它应该在/assets.
找到它。你可以这样做:
- 将嵌入指令更新到/src/assets/img…
- 将嵌入指令改为relative: ../assets/img
- 添加assets文件夹作为编译器源路径(但不应该嵌套在src下)
我尝试了很多方法,终于找到了这个问题的解决方案。
Use: Embed('/assets/img/fileNm.jpg')
Don't use: Embed(source='/assets/img/fileNm.jpg')