Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>While Patrick's answer fulfills the question's criteria, it does not cover all use cases. If you are in an area of code that allows you to use an if/else statement then this is a good answer. But if you are in a place where you cannot then you will need a better solution. For example, you may want to do something like this to declare a constant in a class:</p> <pre><code>private var server:String = "http://localhost/mystagingenvironment"; </code></pre> <p>or for a live release:</p> <pre><code>private var server:String = "http://productionserver.com"; </code></pre> <p>(this is an example and I'm not advocating this as production code).</p> <p>I use xml configs and use the loadConfig+="myconfig.xml" to do my configuration instead of passing large numbers of command line params. So in the <code>&lt;compiler&gt;</code> section of your xml config:</p> <pre><code>&lt;define&gt; &lt;name&gt;CONFIG::debug&lt;/name&gt; &lt;value&gt;false&lt;/value&gt; &lt;/define&gt; &lt;define&gt; &lt;name&gt;CONFIG::release&lt;/name&gt; &lt;value&gt;!CONFIG::debug&lt;/value&gt; &lt;/define&gt; </code></pre> <p>This works well for all use cases:</p> <pre><code>CONFIG::debug { private var server:String = "http://localhost/mystagingenvironment"; } CONFIG::release { private var server:String = "http://productionserver.com"; } </code></pre> <p>This has the additional benefit of working consistently across applications. It also does not rely on the 'optimize' flag being true, like Patrick's answer (although I think we can assume that 99.999999% of all swfs have optimize=true, I only set it to false when the optimizer breaks my AS3). </p> <p>It does have the drawback that it doesn't compile all code paths, just the ones that are included. So if you're not using a build server to create release builds and tell you when things break, be prepared for surprise errors when you do your release build ("But it compiled in debug! Crap, I need this to launch now!").</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload