Search code examples
apache-flexantflex4mxmlc

How do I make my Ant Generated swf as small as possible?


I have a flex project and if I build a release version of the application using flash builder with RSLs on my swf is 115k. If however I build the same application using ant the swf is 342k. Without RSLs the swf is 520k.

How do I get the swf to be as small as the one built by FlashBuilder?

Here is my ant file I have another task that copies the rsls.

<project name="EUI Client Application" default="compileClientApp">

<target name="compileClientApp" depends="compileClientBundles">
    <mxmlc 
        file="${CLIENT_PROJECT.dir}/src/${CLIENT_PROJECT.app}.mxml" 
        output="${DEPLOY.dir}/${CLIENT_PROJECT.app}.swf" 
        keep-generated-actionscript="false" 
        actionscript-file-encoding="UTF-8" 
        incremental="false"
        >

        <runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
            <url rsl-url="flex4_4.0.0.7791.swf"/>
            <url rsl-url="framework_4.0.0.7791.swf"/>
            <url rsl-url="framework_textLayout_4.0.0.7791.swf"/>
            <url rsl-url="rpc_4.0.0.7791.swf"/>
            <url rsl-url="textLayout_451.swf"/>
        </runtime-shared-library-path>

        <source-path path-element="${CLIENT_PROJECT.dir}/src" />

        <compiler.library-path dir="${LIBS.dir}" append="true">
            <include name="*.swc" />
        </compiler.library-path>
        <compiler.library-path dir="${DEPLOY_BIN.dir}" append="true">
            <include name="*.swc" />
        </compiler.library-path>

    </mxmlc>
</target>

<target name="generateWrapper">
    <html-wrapper 
        title="${CLIENT_APP_TITLE}" 
        file="${CLIENT_PROJECT.app}.html" 
        height="100%" width="100%" 
        bgcolor="white" application="app" 
        swf="${CLIENT_PROJECT.app}" 
        version-major="10" version-minor="0" version-revision="0" 
        history="true" output="${DEPLOY.dir}" />
</target>

<target name="compileClientBundles">
    <compileBundle bundleName="Modules" source="${CORE_PROJECT.dir}/locale" />
</target>


Solution

  • Thanks for the replies guys but it wasn't either of those.

    turns out all I needed to do was to remove the runtime-shared-library-path stuff as this is already in the flex-config.xml file. I also had to change the static-link-runtime-shared-libraries to false (so it's dynamic).

    I've copied the flex-config.xml file into my build directory and use that so I can safely make changes.

    This is with Flex 4 BTW - nto sure if I made that very clear.

    my ant file now looks like this:

    <project name="EUI Client Application" default="compileClientApp">
    
    <target name="compileClientApp" depends="compileClientBundles">
        <mxmlc 
            file="${CLIENT_PROJECT.dir}/src/${CLIENT_PROJECT.app}.mxml" 
            output="${DEPLOY.dir}/${CLIENT_PROJECT.app}.swf" 
            keep-generated-actionscript="false" 
            actionscript-file-encoding="UTF-8" 
            optimize="true" incremental="false"
            link-report="${DEPLOY_BIN.dir}/app_link_report.xml"
            >
    
            <load-config filename="${basedir}/flex-config.xml" />
    
            <define name="CONFIG::stub" value="false" />
            <define name="CONFIG::release" value="true" />
    
            <source-path path-element="${CLIENT_PROJECT.dir}/src" />
    
            <compiler.library-path dir="${LIBS.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
            <compiler.library-path dir="${DEPLOY_BIN.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
        </mxmlc>
    </target>
    
    <target name="generateWrapper">
        <html-wrapper 
            title="${CLIENT_APP_TITLE}" 
            file="${CLIENT_PROJECT.app}.html" 
            height="100%" width="100%" 
            bgcolor="white" application="app" 
            swf="${CLIENT_PROJECT.app}" 
            version-major="10" version-minor="0" version-revision="0" 
            history="true" output="${DEPLOY.dir}" />
    </target>
    
    <target name="compileClientBundles">
        <compileBundle bundleName="Modules" source="${CORE_PROJECT.dir}/locale" />
    </target>