Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThis seems like the most elegant solution. less compiler parameters, and a nice separation in an external XML file. To get this to work, the XML file should contain an additional "flex-config" root element, as seen here: http://help.adobe.com/en_US/air/build/WSfffb011ac560372f2012b5a4128cca83a39-8000.html. I also found this: http://www.flashdevelop.org/community/viewtopic.php?f=13&t=9696 which uses an 'append=true' attribute. I've tried all of this, but still my application does not work the way it did without the xml arguments. it does compile though. Anyone having similar problems?
      singulars
    2. COi cannot seem to edit my previous comment, but: after re-reading the drawback, it makes sense. I'm using aditional source paths for my project, including a library project. To add: not only release builds will break. also regular debug builds :( Which alltogether is really bad, because this is a nice and clean way to conditional compiling. Ah well, on to quick & dirty & working then.
      singulars
    3. COSorry to hear you are having issues. I have had good luck with XML files and they are really, really good to have when you are working on really big projects with, say, 5 development environments! Here is an example flex config xml that I used for a small prototype. This is pretty similar to what I would use on a large scale project: http://enemyhideout.com/example_flex_configs/game-flex-config.xml
      singulars
 

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