Historical content: I wrote this article over 11 years ago on 2005-05-21. You are viewing an archived post from my old WordPress blog. The archive contains over 1,600 articles written over a ten year period. The formatting and contents of the posts may not display perfectly.
FAMES: FAME + Swfmill = Fully open source flash
The acronyms they keep a-growin'. I started out with AME (ASDT, MTASC and Eclipse), got the Flashout plugin working and entered the world of FAME before getting my Borg on and assimilating _root. I knew I was well on my way to open-source Flash development but there was still a piece of the puzzle missing: How do I create my initial SWF, its library, resources, etc.
Enter swfmill by Daniel Fischer. Swfmill is a wonderful little command line tool that allows you to go from XML to SWF (using a dialect called swfml) and vice-versa. The path to totally open-source Flash development thus makes our acronym FAMES (which I'm sure Jesse would pronounce "famous"!)
Here are the steps to recreate the FAMES swf you see above:
1. Create a new ActionScript project in ASDT (Eclipse)
2. Create a new XML file called application.xml. This is the swfml file that Swfmill will compile to create the skeleton swf that contains your library.
3. Add the following code to the swfml file:
<?xml version="1.0" encoding="iso-8859-1"?>
<movie width="320" height="240" framerate="30">
<clip id="spheres" import="library/spheres.png"/>
4. Create a new AS File to use as the main application class and call it Application.as. Here is the code for Application.as:
class Application extendsMovieClip
// Clips attached dynamically from Swfmill library
var sW:Number = null; // Stage width
var sH:Number = null; // Stage height
privatefunction Application (target)
// Link movie clips to classes
Object.registerClass("spheres", Particle );
// Assimilate the target
target.__proto__ = this.__proto__;
target.__constructor__ = Application;
this = target;
Flashout.log("Application initialized: " + this);
// Store stage dimensions for easy look-up
sW = Stage.width;
sH = Stage.height;
// Draw border around the stage
lineStyle(1, 0x000000 );
lineTo( sW, 0);
lineTo( sW, sH );
lineTo(0, sH );
// Create a caption
var captionTextFormat = newTextFormat();
captionTextFormat.size = 12;
captionTextFormat.font = "_sans";
var captionText:String = "Made with FAMES (FAME + Swfmill)";
var captionTextExtent:Object = captionTextFormat.getTextExtent( captionText );
var captionWidth:Number = captionTextExtent.textFieldWidth;
var captionHeight:Number = captionTextExtent.textFieldHeight;
The important new bit of functionality here concerns linking the "spheres" clip to the Particle class (achieved with the Object.registerClass statement in the constructor) and attaching instances of it on stage.
Before compiling the project, you need to use Swfmill to create the application.swf. To do this, open up a command prompt and enter the following command from your project folder (make sure you add swfmill.exe to your path first):
swfmill simple application.xml application.swf
6. Finally, you need to configure Flashout. To do this, browse to the Application class to set it as the "Root (main) class" and browse to the application.swf file created by Swfmill to set it for the "Path to swf" option. Hit "compile" and you should see the SWF run!
FAMES opens up a whole new world of cool possibilities.