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

    Using Config Constants to toggle implementations

    December 22nd, 2010

    Our product relies on a “SWF to EXE” solution to give it drag, document CRUD and other “Desktop” functionality.

    The two products contending are MDM Zinc and Screentime mProjector, both have their Pros and Cons but both essentially do whats needed.

    But we are not resolved on either of them yet and need to toggle them as we progress.

    This is where Config Constants lends a hand. By setting these compiler constants in your IDE or ANT builds you can toggle what gets compiled:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
      private var _iDesktopS:IDesktopService;
      private var _iDragS:IDragService;

      private function configure():void
      {
       LIBRARY::MDM {
        _iDesktopS = new MDMDesktopService();
        _iDragS = new MDMDragService();
       }
       
       LIBRARY::MPROJECTOR {
        _iDesktopS = new MProjectorDesktopService();
        _iDragS = new MProjectorDragService();    
       }
       
       _iDesktopS.setup(this);
       _iDragS.setup(this);
      }

      private function handleCloseRequest(e:MouseEvent):void
      {
       _iDesktopS.close();
      }

    Using config constants that you define in the publish settings, you can specify whether certain lines of ActionScript code are compiled or not.

    http://help.adobe.com

    Setup is done easily in Flash:

    Or you can implement it in your ANT build:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
      <target name="communicator">
       <mxmlc file="${SRC_DIR}\coza\d6technology\communicator\communicator.mxml"
        output="${BIN_DIR}\communicator.swf"
        load-externs="${BASE_DIR}\shellLinkReport.xml"
        link-report="${BASE_DIR}\communicatorLinkReport.xml"
        debug="${DEBUG}"
        default-frame-rate="${FRAME_RATE}"
        optimize="true"
        static-rsls="true">
         
        <define name="LIBRARY::MDM" value="false"/>
        <define name="LIBRARY::MPROJECTOR" value="true"/>
       
        <keep-as3-metadata name="Inject" />
    ........

    You are not just restricted to boolean values, although i haven’t tested this, but you can match the constant to a value as shown here: http://www.ericd.net/2009/01/config-constants-in-flash-cs4.html


    Uninstall Script for our Mac Product

    December 3rd, 2010

    CIC – Communicator Installer Creator, the AIR/Flex app i created to help our production team create custom versions of the D6 product and its installer, uses a PackageMaker process to create the Mac installer.

    As with most Mac installer software i researched, there is no uninstaller option, let alone the option to remove added Application Data or Login items added to system events. So i created a shell script which uses a mix of AppleScript and OSX commands to do such things.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    #!/bin/sh

    TITLE="St Peter's Schools"

    // stop the process running
    osascript -e "tell application \"$TITLE\" to quit"

    // removes the "Application Data"
    rm -R "$HOME/Library/Application Support/com.d6technology/$TITLE"

    //removes the Application
    rm -R "/Applications/$TITLE.app"

    // removes the startup item
    osascript -e "tell application \"System Events\" to delete login item \"$TITLE\""

    It has not been integrated into production yet, but as a proof of concept it’s there or there about.