Compiling Flex without Flash Builder

Hope you have some knowledge about Flex, if not please have a look at this.

Flex applications can be compiled using mxmlc compiler that is part of the Flex SDK, located in the bin folder of course.





Just create an MXML file, go to command prompt. Set the path to the bin folder of the Flex SDK. Type

mxmlc filename.mxml

This will compile the input mxml file to the desired swf file. But it will display warnings like

Required RSLs:
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/framework_4.6.0.23201.swz with 1 failover.
http://fpdownload.adobe.com/pub/swz/tlf/2.0.0.232/textLayout_2.0.0.232.swz with 1 failover.
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/spark_4.6.0.23201.swz with 1 failover.
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/sparkskins_4.6.0.23201.swz with 1 failover.
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/mx_4.6.0.23201.swz with 1 failover.

To avoid this either you have to specify the RSL path, or link it statically with the compiler flag. Now type

mxmlc -static-link-runtime-shared-libraries=true filename.mxml 

This will generate an swf file, which can be opened using Adobe Flash Player or any browser that has the Flash player plugin. More details about RSLs and their linking can be found in the Adobe Flex website.

The command is bit longer to type each time. You can write a simple batch file to automate the work. I wrote the below shown batch file and copied to my System32 directory. The file is,




Saving the path and reusing it allows to compile multiple times without the need to reopen the command prompt. This file will take the input mxml file as argument. I am not insisting to use the same file for your compilation, just have this one as reference and build your own. Also, a build.mxml can also be used to build the project, for that you need Apache Ant.

Suggestions to this blog are most welcome. If you face any issues with the steps above, just drop a comment.

See also Hello World In FlexIPv4 Validator in FlexCalculator in Flex,  Simple Animation in FlexMastering Alert - FlexNativeProcess - AIR.

3 comments:

  1. Thanks for sharing this useful info. Keep updating same way.
    Regards,Siddu online Training

    ReplyDelete
  2. Couldn't it be set up once and for all in the compiler config somewhere? (e.g. flex-config.xml perhaps?)

    ReplyDelete
  3. This is really too useful and has more ideas from your blog. Keep sharing many techniques..........................Please contact us for Oracle Fusion SCM Training details in our Erptree Training Institute

    ReplyDelete