Kyle Ward: Flex, AIR, Flash Developer.   
  • Home
  •  

    Tips for setting up ANT

    November 17th, 2010

    I have multiple swfs in my project that need to be published in a variety of ways. Using ANT i can automate mxmlc, compc, cmd calls which allow me to publish swfs, swcs, extract swfs from swc and many more awesome features.

    I found the initial setup of ANT tedious. Here are a few tips for setting up ANT.

  • Download ANT:
    Unzip and copy to your hard drive (like the Flex SDK).
    http://ant.apache.org/bindownload.cgi
  • Make sure you have the Java JDK installed:
    Not the JRE else “Unable to locate tools.jar” error.
    Download
  • Set your Enviromental Variables:
    ANT_HOME [C:\Program Files\ant]
    JAVA_HOME [C:\Program Files\Java\jdk1.6.0_22]
    http://www.java.com/en/download/help/path.xml
  • Place your build.xml and build.properties in your project root:
    http://www.adobe.us/devnet/flex/articles/flex_ant_pt1.html
  • Set path to flexTasks and build.properties in the build.xml:
    1
    2
    3
    4
    5
    <property file="build.properties" />

    <taskdef name="mxmlc" classpath="${FLEX_DIR}/ant/lib/flexTasks.jar" classname="flex.ant.MxmlcTask"/>
    <taskdef name="compc" classpath="${FLEX_DIR}/ant/lib/flexTasks.jar" classname="flex.ant.CompcTask"/>
    <taskdef name="html-wrapper" classpath="${FLEX_DIR}/ant/lib/flexTasks.jar" classname="flex.ant.HtmlWrapperTask"/>

    http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html

  • FlashDevelop plugin:
    You can run your build.xml from the CMD or a .bat file.
    Most IDEs provide ways to use your ANT file [FlexBuilder, FDT, IntelliJ]
    http://code.google.com/p/fd-ant-plugin

  • mx:Style preventing a mx:Module being Garbage Collected

    November 1st, 2010

    Whilst profling i noticed that one of my mx:Module would not be cleared from memory.

    After an elimination process i found mx:Style to be the guilty party:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <mx:DateChooser   xmlns:mx="http://www.adobe.com/2006/mxml"
        weekDayStyleName="weekDayStyle">
       <mx:Style>
        .weekDayStyle {
         fontWeight: bold;
         ...
        }    
       </mx:Style>
       <mx:Script>
        <![CDATA[
         private function styleWeekDay():void
         {
          var style:Object = iStyleSheetM.getStyle(".dateChooserWeekDay");
          var declaration:CSSStyleDeclaration = styleManager.getStyleDeclaration(".weekDayStyle");
             
          declaration.setStyle("fontWeight", style.fontWeight);    
          ....
         }
        ]]>
       </mx:Script>    
    </mx:DateChooser>

    (My modules are styled from an external css file that gets loaded once after the applications startup and then gets implemented as you’ll see above. ie the default values in the script block get replaced by the values from the external css file.)

    Remove the mx:Style block and the mx:Module would be collected.
    But i need the style and therefore i found a solution:

    1
    2
    3
    4
    5
         public function shutdown():void
         {
          styleManager.clearStyleDeclaration(".weekDayStyle", true);
          ...
         }

    Perhaps i should use a better way to style my mx:Module, but at least this is a solution for now.