Go to the base directory of your Flex code (and close Flex Builder if it works - it becomes restless if you change things while it works). Run this to change all your trace instructions. I recommend checking the tree on git or something first, and then running diff afterwards (or cp -r tree to make diff -r or something else). The only serious case this will ruin is if you have semicolons inside the trace lines:
find . -name '*.as' -exec perl -pe 'BEGIN{ undef $/; }s/trace([^;]*);/CONFIG::debugging { trace $1 ; };/smg;' -i {} \; find . -name '*.mxml' -exec perl -pe 'BEGIN{ undef $/; }s/trace([^;]*);/CONFIG::debugging { trace $1 ; };/smg;' -i {} \;
Then configure in your designers Project-> Properties-> Flex Compiler-> Additional compiler the following:
-define=CONFIG::debugging,true -define=CONFIG::release,false
And use:
CONFIG::release { }
for the sentence "#else". This was the solution I chose after reading this question and answer.
Also be careful:
if( foo ) { } else CONFIG::debugging { trace("whoops no braces around else-clause"); };
those. if you have ONLY one of them in the if or else block or in any block, and its bare block is without bindings, then regardless of whether it is compiled, it will complain.
source share