ichiba.ch Download the KAYWA Reader!
En | De | Fr

Feed2Mobile

pixelate environment: Blog - Debug and Release Builds with AS3 Conditional Compilation

While working on our upcoming game Mr. Bounce I was searching for a way to compile debug and release builds from the same source in AS3. Our game project includes things like an internal level editor and cheat keys that we need for developing and testing the game, but should not go in the release version of the game.

I stumpled across something called Conditional Compilation on Ryan Taylors Blog a new feature of the Flex 3 SDK. It allows you to define constants (Booleans, Strings, Numbers or expressions) at compile time, which are globally accessible within the source of your application.

You can define your constants on the command-line with mxmlc, in a Flex Ant Task or using a configuration file. See Adobes documentation for more information on this.

For our game we defined the debug and release constants in the flex_config.xml file that is located in the Flex 3 SDK folder inside the frameworks folder. Both constants are Booleans using the CONFIG namespace.


   
    
      CONFIG::debug 
      true
   
   
      CONFIG::release 
      false
    

Now we can check for the debug and release constants in the source code and execute the correct code for the target build:

private function init():void
{
   CONFIG::debug
   {
      // Only init the level editor for the debug build
      initEditor();
   }

   initGame();
}

We could also specify alternative versions of a function for the different builds:

CONFIG::debug
private function init():void
{
   initEditor();
   initGame();
}

CONFIG::release
private function init():void
{
   initGame();
}

Note: this is how this feed will look on your mobile device.

Get mobile!

This QR Code will let any user whose mobile phone is equipped with a QR Code Reader to easily reach and bookmark the mobile version of «pixelate environment: Blog»

To add this QR Code to your Blog or Website, simply copy-paste the following Javascript blurb into your Blog template.

Feed2Mobile v1.0-BETA3 CONTACT US: KAYWA // TECHNOPARKSTRASSE 1 // 8005 ZUERICH // SWITZERLAND // info@kaywa.com