the blog
Back to -Blog

ActionScript Conditional Compilation

All Done With Symbols!
by Huw Collingbourne
Monday 1 June 2009.

There are many times when you may want to include or exclude specific blocks of code selectively when you compile a project. For example, when debugging you may want to include a whole load of tracing or logging statements which you want to exclude from the release version of your program.

Amethyst gives you a very simple way of controlling conditional compilation. This is done by setting options in the Project Properties pages (available from the Project menu).

You just define configuration symbols with names such as CONFIG::debug and CONFIG::release where the first part (here ‘CONFIG’) is a namespace and the next part (here ‘debug’ or ‘release’) is the defined symbol. Finally, you need to append a comma followed by a Boolean value ‘true’ or ‘false’. You can do this on the Configuration page of Project Properties. Add the symbol in the ‘Symbol to add:’ field and click the button to add it to the list of defined symbols.

You can switch between different sets of defined symbols (say for a debug or release compilation) just by selecting the Configuration name at the top of the Properties page.

Now, in your code, bracket out those lines you wish to include or exclude when specific symbols are defined to be true or false:

Bookmark and Share   Keywords:  Amethyst  ide  tutorial
© SapphireSteel Software 2014