actionscript-3conditional-compilationmxmlc

mxmlc (flex compiler) ignores "define" from xml configs


From Adobe's documentation:

To set the value of these constants in the flex-config.xml file, rather than on the command line, you write this as the following example shows:

<compiler> 
    <define append="true"> 
        <name>CONFIG::debugging</name> 
        <value>true</value> 
    </define> 
    <define append="true"> 
        <name>CONFIG::release</name> 
        <value>false</value> 
    </define> 
</compiler>

The problem is that compiler doesn't actually take them into account and giving me compilation errors like "Error: Access of undefined property debugging." since I have that in my ActionScript code.

If I define them via arguments ("-define+=CONFIG::debugging,true") everything is OK.

I thought maybe my config is not used at all, so I malformed it — mxmlc points that out. So config is actually loaded into compiler.

Any hints? Thank you.


Solution

  • So it was the XML problem — as I actually had strings, not booleans, in config — you should not forget to write the proper XML (weird that compiler didn't say me back anything).

    <value>&quot;MyStringValue&quot;</value> 
    

    Or easier:

    <value>'MyStringValue'</value> 
    

    And double-quoting ('"MyStringValue"') is when you're using arguments.