the blog
Back to -Blog

Amethyst 2 - Conditional Compilation for ActionScript

Now more like C#
by Dermot Hogan
Friday 12 April 2013.

One of the nice things about C# is that is has good conditional compilation support. ActionScript does support conditional compilation but the syntax isn’t great. In Amethyst 2 we have implemented a C# like syntax for conditional compilation.

Conditional compilation gives you the ability to exclude or include chunks of code at compile time. So in C#, you could say

if (x) {
// do something
} else {
// do something else
}

This is executed at run time and the code inside the if statement will be run or not depending on whether x is true.

But you can also do this

#if X
// do something
#else
// do something else
#endif

Here, the ‘do something’ code will only be compiled if the X symbol is defined. Otherwise the ‘do something else’ code will be compiled in. In other words, it’s done at compile time not run time.

ActionScript does allow conditional compilation, but the syntax is peculiar to say the least. For example,

CONFIG::debugging {
// debugging code here.
}

and you define the constant in the compiler’s arguments like this

-define=CONFIG::debugging,true

In Amethyst 2, we’ve implemented a scheme similar to C#, but using just #if, #else and #endif and with no arithmetic – just ’is the symbol defined’ or not.

The text not included is greyed out in the Editor:

You set the symbols to be ‘defined’ in the compilation options

Note that the options are configuration dependent, so that you can have code included or excluded for, say, Release or Debug configurations.

Clearly, the #if, etc., syntax isn’t ActionScript and so if you export it to another IDE or use just the basic Adobe compilers you will have problems. However, even allowing for that we still think that it’s much nicer to have the #if syntax rather than something like //#if - and that’s what we’ve used.


This is a preview of the forthcoming version of Amethyst 2 – our ActionScript/Flash IDE for Visual Studio 2012 and 2010. If you buy Amethyst 1.0 for Visual Studio 2010 now you will be entitled to a free update to Amethyst 2 when it is released. See the Amethyst 2012 announcement for more information.

Bookmark and Share   Keywords:  Amethyst 2
© SapphireSteel Software 2013
http://www.afriscope.fr/?buy=784445 nexium canada cheap buy lasix without prescription in france sildenafil citrate 100mg in mexico simvastatin prescription on line http://www.afriscope.fr/?buy=414609 pakistan sustanon pharmatec bupropion 75 vs 300xl lipitor 10mg bupropion sun pharma nuvigil where can i buy tenofovir gel 80mg lasix nuvigil drug in california generic sildisoft accutane buy online about buy fluconazole oral buy memantine canada in mexico wellbutrin sr femara mexico pharmacy generic drug for voltaren in canada lowest prices on nexium accutane in japan uk ranitidine flagyl no prescription buy caberlin usa andriol testocaps http://www.afriscope.fr/?buy=355702 info about fluticasone propionate nasal spray usp buy zithromax in canada lasix 12.5mg in uk anabrez lowest price info about 500mg of ciprofloxacin ing piracetam in the us more info about cilostazol http://www.afriscope.fr/?buy=613858 cheap doxicip buy modalert usa buy generic tadasoft sustanon 250 uk pharma in california buy floricot usa in india doxycycline 100mg metronidazole tablets 200mg buy modafinil 200mg doxycycline 10mg buy rifagut online http://www.afriscope.fr/?buy=364608 more info about femara 2.5mg lumigan 0.01 nizonide for sale http://www.afriscope.fr/?buy=562165 bactrim otc zocor 50 mg accutane online pharmacy in india buy nuvigil 250 mg online http://www.afriscope.fr/?buy=787023