关于Flex Ant的相关注意事项

1、代码方面:

如果是Embed的方法,务必按以下方式写,注意反斜杠的位置。

在mxml文件中:

<mx:Image  source="@Embed('/cn/com/1.png')"/>  

在CSS文件中:

backgroundImage:Embed(source="/cn/com/1.png");

在AS文件中:

[Embed(source="/cn/com/1.png")]
        public var zmouse : Class;

2、图片以及附件的处理方面:

如果是Embed进去的,这些就不需要处理了,那未打包的资源就是一个比较麻烦的地方,偶也没有找到比较好的方法,似乎只能一个个写,参考其提供的样例:

<compc fork="true"
               output="${basedir}/${THEME_NAME}.swc">
            <!-- If you change this, update ${local.playerglobal.version} above. -->
            <target-player>10</target-player>
            <jvmarg line="${compc.jvm.args}"/>
            <include-classes>ArcadeClasses</include-classes>
            <source-path path-element="${basedir}/src"/>
            <library-path />
            <external-library-path dir="${FLEX_HOME}/frameworks/libs">
                <include name="player/${local.playerglobal.version}/playerglobal.swc"/>
                <include name="framework.swc"/>
                <include name="spark.swc"/>
                <include name="textLayout.swc"/>
                <include name="osmf.swc"/>
            </external-library-path>
            <include-file name="defaults.css" path="${basedir}/src/defaults.css"/>
            <include-file name="assets/flex_skins.swf" path="${basedir}/src/assets/flex_skins.swf"/>
            <include-file name="preview.jpg" path="${basedir}/src/preview.jpg"/>
            <include-file name="metadata.xml" path="${basedir}/src/metadata.xml"/>
            <locale/>
            <accessible>true</accessible>
        </compc>

3、样式的处理:

如果采用的动态加载样式 ,那么尽量将相关的库打包至样式的SWF中,否则可能会出现部分样式加载延迟的问题,关于static-link-runtime-shared-libraries的使用可以Google一下!

 <target name="buildcss" depends="init">
            <mxmlc file="${SRC_DIR}/cn/com/egova/umgis/common/style/CustomStyle.css" 
                output="${DEPLOY_DIR}/cn/com/egova/umgis/common/style/CustomStyle.swf">
                <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries> 
                </mxmlc>
     </target>

4、关于文件大小

采用Ant打包的文件相比使用Flash Builder自动编绎生成的文件大概要小一半左右,这是因为其自动编译的文件为了避免出错,会将一些共享库打包至SWF中,因此会造成SWF庞大,但至于使用Ant打包后的是不是会有其他问题,暂时还没有验证。

参考资源:

http://www.petersheim.org/wiki/index.php/Flex_Ant_Task

http://blog.ityao.com/archives/751

http://mxcode.com/2010/11/flex-ant-file-sample/

posted @ 2011-11-01 10:10  GIS小能  阅读(690)  评论(0编辑  收藏  举报