-
Notifications
You must be signed in to change notification settings - Fork 5
Compiling a swf
Compiling a swf file is really simple in buildr-as3, let's say we want to compile the following "Main" class into a swf:
package
{
import flash.display.Sprite;
public class Main extends Sprite
{
public function Main()
{
graphics.beginFill(0xFF0000)
graphics.drawCircle(100,100,100)
graphics.endFill()
}
}
}
Let's stick with the buildr convention for now and put our Main.as file in the default source directory src/main/as3 and move on to writing our buildfile.
require "buildr/as3"
define "RedCircle" do
end
There are no instructions for buildr yet on how to compile the "RedCircle" project. Let's add it!
First we need to tell buildr which compiler to use for this project. The compiler we want to use is mxmlc, because it compiles our code into a swf.
compile.using :mxmlc
Next step is to define which version of the FlexSDK should be used for this project:
compile.using :flexsdk => FlexSDK.new("4.5.0.20967")
The third and last step is to point the mxmlc compiler to our Main.as class file. We do this with the helper function _(underscore), you can find out more about it here: Directory layouts.
compile.using :main => _(:source,:main,:as3,"Main.as")
We can combine this into a single call of compile.using which results in the following buildfile:
require "buildr/as3"
define "RedCircle" do
compile.using :mxmlc,
:flexsdk => FlexSDK.new("4.5.0.20967"),
:main => _(:source,:main,:as3,"Main.as")
end
As you can see, defining your compile strategy in buildr is very concise and readable.
To compile this project simply open the terminal, cd into your project directory and type buildr compile to start the compilation.
You can find the example project here.