Search code examples
flashactionscript-3mxmlc

Why MX libraries are in my SWF?


I have a pure AS3 project. I use Ant to build it. Here is a part of my ant script:

<target name="mxmlc">
    <exec executable="${flex.home}/${mxmlc}" failonerror="true">
        <arg line="-compiler.include-libraries=${lib}"/>
        <arg line="-compiler.incremental=false"/>
        <arg line="-compiler.optimize=true"/>
        <arg line="-debug=false"/>
        <arg line="-default-background-color=0x${background.color}"/>
        <arg line="-default-frame-rate=60"/>
        <arg line="-default-size 800 600"/>
        <arg line="-static-link-runtime-shared-libraries=true"/>
        <arg line="-source-path='${src}'"/>
        <arg line="'${basedir}/${src}/${src.file}'"/>
        <arg line="-o=${bin}/${output.file}"/>
        <arg line="-use-network=true"/>
    </exec>
</target>

The problem is that my resulting SWF is really big. When I checked what is inside I saw that it has mx.* libs from Flex. Why it is like this? How to kick mx.* from my SWF?

p.s. In my code I don't use anything from mx.* library.


Solution

  • Even though your code doesn't import any mx.* classes directly, some of the classes you do import might have imports of their own. Are you using any of the built-in Flash, Flex or Spark components, for example?

    Anyway, I wouldn't worry about the mx.* imports, but rather check the assets you are using:

    • Components (Can you do without some and replace them with your own, simpler implementations?)
    • Fonts
    • Images
    • Movies
    • Sounds

    These are usually responsible for bloating your SWFs, and adjusting image quality, or reducing the number of characters in an embedded font, for example, can greatly reduce your file size.