Compiling ActionScript 3 Scripts with 'mxmlc'

This section provides a tutorial example on how to use the Flex compiler, mxml, to compile Flash applications written in ActionScript 3 language.

Adobe Flex compiler, mxmlc, can also be used to compile Flash applications written in ActionScript 3 language.

To test mxmlc with ActionScript 3 script, let's see the example written in SWFC script, circle.sc, again:

// MyMovieClip.as
// Copyright (c) 2010, HerongYang.com, All Rights Reserved.
//
package com.herongyang {
   import flash.display.*;
   import flash.text.*;
   public class MyMovieClip extends MovieClip {
      private var green:uint = 0x00ff00;
      private var black:uint = 0x000000;

// Building my first frame in the constructor
      public function MyMovieClip() {
         addCircle();
         addText();
      }

// Building a shap object
      private function addCircle():void {
         graphics.beginFill(green);
         graphics.lineStyle(5, black);
         graphics.drawCircle(75, 75, 50);
         graphics.endFill();
      }

// Building a text object
      private function addText():void {
         var object:TextField = new TextField();
         object.text = "Green";
         object.x = 50;
         object.y = 50;
         addChild(object);
      }

   }
}

Since class package name, com.herongyang, is used, we need to put this class source code in a sub folder path that matches the package name:

C:\herong>copy MyMovieClip.as com\herongyang\MyMovieClip.as

Now we are ready to compile this ActionScript 3 class source code:

C:\herong>\local\flex\bin\mxmlc -compiler.source-path=.
   com\herongyang\MyMovieClip.as

Loading configuration file C:\local\flex\frameworks\flex-config.xml
C:\herong\com\herongyang\MyMovieClip.as: Warning: This compilation 
unit did not have a factoryClass specified in Frame metadata to load
the configured runtime shared libraries. To compile without runtime 
shared libraries either set the -static-link-runtime-shared-libraries
option to true or remove the -runtime-shared-libraries option.

C:\herong\com\herongyang\MyMovieClip.swf (839 bytes)

Open com\herongyang\MyMovieClip.swf in a Web browser. You will see:

mxmlc - My MoiveClip
mxmlc - My MoiveClip

Cool. I am able to use mxmlc to compile a Flash application written in ActionScript 3 language.

Table of Contents

 About This Book

 Introduction of Adobe Flash

 Adobe Flash Player Plugin for Firefox

 Adobe Flash Player Plugin for Chrome

 Adobe Flash Player Plugin for Safari

 Adobe Flash Player ActiveX for IE

 Using "object" Elements for Flash Files

 Using "embed" Elements for Flash Files

 "mp3player" - MP3 Music Player

 SWFObject - Hidding "object" behind JavaScript

 Flash Player Projector

 SWFTools - SWF File Manipulation Tools

 SWFC Script to Generate Flash SWF Files

 ActionScript Embedded in SWFC Script

 AS3Compile - ActionScript 3 Compiler

Adobe Flex SDK 4

 Downloading and Installing Flex SDK 4.1

 "mxmlc" - Adobe Flex Compiler

 Spark Component Architecture

 MXML Example Using Spark Components

Compiling ActionScript 3 Scripts with 'mxmlc'

 SWF Disassembler in Flex SDK

 Dumping Simple SWF Files

 Dumping SWF Files Containing ActionScript 3 Statements

 Dumping SWF Files Generated from ActionScript 3 Classes

 Dumping SWF Files Generated from MXML Applications

 SWF File Structure and Tags

 SWF File Processing Rules

 SWF Files for Video and Audio Streams

 Outdated Tutorials

 References

 Full Version in PDF/EPUB