Useful mxmlc command line options

-file-spec File1.mxml [File2.mxml ...]

Used to specify the file names which are to be compiled by the mxmlc compiler.

-output dir/out.swf

Use this option to specify the output directory and/or file name.

-source-path dir1 [dir2 ...]

By default, the mxmlc compiler looks in the current directory only for the required files. If you are using some source files which are located in another directory or multiple directories, use this option to specify those locations.

-default-script-limits 150 10

The first parameter (e.g. 150) specifies the maximum level of recursion allowed. The second parameter defines the maximum script execution time (in seconds).

-incremental=true

By default, the mxmlc compiler does a clean build each time it is invoked. To use incremental builds, specify this option. In case of incremental builds, the compiler compiles only those files which have changed from the last build.

-load-config=config.xml

Instead of specifying the compiler options on the command line, you can put all the options in the config.xml file. By default, the mxmlc compiler reads the parameters from the flex-config.xml file in the SDK/frameworks directory. However, if you use this option, the flex-config.xml file is ignored altogether. Many of the options specified in that file are required for mxmlc to run. Hence, you’ll need to specify all the required options in your custom configuration file.

-load-config+=config.xml

Since specifying all the required values in the config.xml file is painful, use this option to load your configuration file in addition to the default flex-config.xml file. The values in your config.xml file override the default values in the flex-config.xml file. The remaining values are read from the flex-config.xml file.

Advertisements

Gotcha with ActionScript ‘const’

ActionScript (like JavaScript) lets you access object properties using two different notations. Consider the following class

class A
{
     public const CONSTANT:int = 34;
}
var a:A = new A();

 

The CONSTANT property of object a can be referred using the following two formats:

  • a.CONSTANT
  • a["CONSTANT"]

Since CONSTANT is declared using const, it cannot be assigned a new value later on. So the following code doesn’t compile (as expected):

a.CONSTANT = 23;

 

However, the following code compiles and only throws an exception at run-time:

a["CONSTANT"] = 23;

 

Beware of this behavior of ActionScript when using consts in your code!

Declaring Constants in Java/JavaScript/ActionScript

This has confused me some times in the past, so I thought I’d put it here for easy reference.

Java:

final int VALUE = 10;

JavaScript:

const VALUE = 10;

ActionScript:

const VALUE:Number = 10;

 

The point of confusion is that const is a reserved word in Java but is not used for declaring constants (yet!). Java uses the final keyword for this purpose.

Flex Builder 3.2 and AIR projects

I was facing problem running AIR projects since morning. Reinstalled Flex builder 3.0.2 a couple of times. I thought it was an issue related to upgrading to Flash Player 10. However, I later found (through google) that to make the older AIR projects run with the new release of Flex builder, you need to change the line

<application xmlns="http://ns.adobe.com/air/application/1.0">

In app.xml to

<application xmlns="http://ns.adobe.com/air/application/1.5">