Defines a script in action

I am trying to transfer assembly number from Hudson to Flex application.

I found an Adobe document ( http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html ) with conditional compilation, which seems to solve it, but I have to miss something .

So, in my ant build file, I have: -

<mxmlc file="${app.dir}/${application.name}.mxml" output="${dist.dir}/${application.name}.swf" context-root="${application.name}" debug="true" locale="${locales}" allow-source-path-overlap="true"> <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/> <compiler.library-path dir="${lib.dir}" append="true"> <include name="*.swc" /> </compiler.library-path> <define name="BUILD::BuildNumber" value="'20100707.800'"/> <source-path path-element="${src.dir}"/> <source-path path-element="${cfg.dir}"/> <source-path path-element="${locale.dir}" /> </mxmlc> 

Then I try to get using

 public static const buildNumber:String = BUILD::BuildNumber; 

However, the compiler is rejected with:

SomeModel.as (31): col: 47 Error: access to an undefined BUILD object.
[mxmlc] private static const _buildNumber: String = BUILD :: BuildNumber;

Any suggestions?

+6
flex compilation actionscript-3 const
source share
4 answers

A combination of other suggestions seems to work.

This should go in your build.xml file (assuming your build.xml has already assigned the value BUILD_NUMBER to this point):

 <mxmlc> ... <define name="CONFIG::build" value="&quot;${BUILD_NUMBER}&quot;" /> ... </mxmlc> 

Note the use of &quot; without quotes. Also note that this syntax can be used with compc.

Then your ActionScript code might have something like this:

 public static const buildNumber:String = CONFIG::build; 

I don't think you should definitely use the CONFIG namespace, but this is a popular convention.

+2
source share

This is definitely a citation issue. For some time I struggled with this. However, I use the tag in ant to run mxmlc and compc, so I'm not sure if my resolution is the same. This definitely works for me tho:

 <arg value="-define+=ENV::build,&quot;${build.id}&quot;" /> <arg value="-define+=ENV::version,&quot;${build.version}&quot;" /> 

May I suggest you try:

 <define name="BUILD::BuildNumber" value="&quot;20100707.800&quot;"/> 
+1
source share

For Laurynas Stančikas comment, you should use &quot; :

To pass a string using Ant (when using mxmlc), use &quot; . For example:

  <compiler.define name="NAMES::AppName" value="&quot;'FooBar'&quot;" /> 

Have you tried this?

0
source share

I just solved the javascript flashvars issue with quotes, which inspired the idea of ​​"try this":

Try shielding:

<compiler.define name = "NAMES :: AppName" value = "\ 'FooBar \'" />

0
source share

All Articles