Steps in compiling ActionScript file (.as) using mxmlc of Flex SDK.
Obtaining the Compiler
- To create SWF files from ActionScript, you will need a compiler, the program that interprets ActionScript code and translates it into the machine code used in SWF files. The compiler used to compile ActionScript or MXML is mxmlc.exe. mxmlc.exe can be downloaded free, just download the latest Flex SDK, and you will obtain the MXMLC.EXE.
MXMLC.EXE - can be found in SDK_PATH/bin/mxmlc.exe.
mxmlc.exe is a launcher that runs the MXML and ActionScript 3 compiler that converts MXML files (.mxml) and ActionScript 3 files (.as) into published SWF files (for the purposes of this tutorial, we will be primarily concerned with ActionScript 3 files though the compiler handles both as well as some other file types used in the ultimate generation of the SWF). The real compiler is a Java jar file located in the lib directory of your Flex Builder/SDK install and not mxmlc.exe itself. Because of this, to work with the compiler you'll A) need to make sure you keep all of those files of which the compiler is dependant (i.e. dont go moving around just mxmlc.exe and expect it to work), and B) need to have the Java runtime environment installed on your system. If you've installed Flex Builder you won't have to worry about this since it will take care of this for you. If you just got the SDK, however, and haven't had Java installed on your computer, you can download and install the Java runtime environment from http://java.sun.com.
In the directory containing mxmlc.exe you may notice some other executables. compc.exe is for creating SWC files (pre-compiled component file), and fdb.exe is the command line debugger. Here we are sticking to just using mxmlc.exe which is all you need to get started using ActionScript 3.
For mxmlc command line options, just visit http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_13.html
How to compile ActionScript in mxmlc
- create a batch file. Here is a sample of batch file I used for compiling fonts.
C:\flex_sdk_126.96.36.19976\bin\mxmlc.exe -static-link-runtime-shared-libraries=true -o output.swf -source-path="C:\_cafepress\devtools\manila\fonts\src\" "C:\_cafepress\devtools\manila\fonts\src\font\Alepholon.as"
- the ActionScript file (I used Alepholon.as here)
* Font library
* @author mykhel
public class Alepholon extends Sprite
,fontStyle ='normal' // normal|italic
,fontWeight ='normal' // normal|bold
public static const fontClass:Class;
public function Alepholon()
Note: This class is to embed font. I get this sample in one of the output file of automation tool in converting Font file (.TFF) into SWF that I have created.
- Run the batch file, and look for the output file. In my example, output file can be found in the directory of the batch file.
Download the sample files here.
Please note, I cannot include the Alepholon font, but you can try the other font. Play around with the batch file, change the path and options.
Original story here.