Firstly, FlashDevelop 3 only runs on Windows XP/Vista, and requires the .NET 2 runtime. Additionally, to compile AS3 code you will need the Java 1.6 runtime and the Adobe Flex SDK. Ok, let’s go!
Part 1 – Downloading, Installing, and Compiling a SWF
Let’s begin by setting things up and compiling our first SWF.
- Download the Adobe Flex SDK (just the SDK at the bottom of the page, not Flex Builder), and unpack it somewhere easy to find (C:\FlexSDK\Flex3\).
- Download the latest version of FlashDevelop, install it and run it.
- Create a New Project, under ActionScript 3 choose Default Project, and give it a name (”hello”).
- In the Project Panel expand the “src” folder and open up “Main.as”
- In the constructor add the code: trace(”hello world!”);
- Hit Ctrl-Enter (or F5). A dialog should pop up asking if you’d like to open the AS3 context settings. Click “OK”.
- In the “Flex SDK Location” input field enter the path from step 1 (or browse to it).
- Hit Ctrl-Enter again. This should compile your code into a SWF and launch it in a tab. The Flex 3 compiler does incremental compiling, so the first compile might take a while, but subsequent compiles should be much faster.
- Make a “whooping” noise! “hello world!” should be displayed in the Output panel. You’ll find the SWF sitting in the “bin” folder. Notice that the project panel let’s you look into the guts of your SWF.. pretty damn sweet!
Part 2 – Some Adjustments
By default, FlashDevelop launches SWFs in it’s own version of the Flash Player. At the time of this writing, the player doesn’t perform quite as well as the official debug version of the Adobe Flash Player (besides, we want all the goodness of the very latest Flash Player!). Also, I find the tabbed view weird. So let’s change our setup a bit.
- Head on over to Adobe downloads, “Download the Windows Flash Player 9 Projector content debugger” and put it somewhere easy to find (C:\FlexSDK\FlashPlayer\)
- Back in FlashDevelop, go to the main menu, click “Tools” and select “Program Settings” (or hit F10)
- In the left panel, under “Plugins” select FlashViewer, and point the “External Play Path” to the debug player executable from step 1.
- While you’re there, change the “Movie Display Style” to “External”. Click “Close”.
- At the top of the Project Panel click the “Project Properties” button (third from the left).
- Under “Test Movie” change the selection to “Play in external player”, and click “OK”.
- Hit Ctrl-Enter. Make the universal “Whazzamm” sound!
Part 3 – Attaching Assets to the Stage
Perhaps “hello world!” is not that thrilling for you. Fine.
- Create a folder called “lib” inside your project folder (alongside “bin” and “src”).
- Fire up Adobe Flash CS3 and create a new Flash File (Action Script 3.0).
- Save it inside the “lib” folder from step 1 and call it “assets.fla”.
- In the Flash IDE grab the Oval tool and draw a circle.
- Select the circle and convert it to a symbol by hitting F8 (or right-click and select “Convert to Symbol…”).
- Give it the name “Circle” and expand the Linkage panel by clicking “Advanced”.
- Under “Linkage” tick “Export for ActionScript” and click “OK”.
- Open up your Publish Settings (Ctrl-Shift-F12), deselect “HTML”, and flip to the “Flash” tab
- Tick “Export SWC”, click “Publish” and click “OK”.
- Save the file and close the Flash IDE.
- Flip back to FlashDevelop, and expand the “lib” folder in the Project Panel.
- Right-click “assets.swc” and select “Add To Library”.
- Replace our “trace” statement with the following code:
var circle:Circle = new Circle();
addChild( circle );
- Hit Ctrl-Enter. Loudly exclaim “Golly, this is the biznis!”.
Part 4 – Extending Assets, Adding Interactivity
Perhaps a plain old circle on the stage doesn’t really do it for you. You want some motion. You want some interactivity. Some filters. Fine then. Let’s do it..
- In the Project Panel, right click the “src” folder, select “New” “Class”, name it “ReactiveCircle” and click “OK”.
- Head to the end of the line “public class ReactiveCircle”, type “extends”, hit Space and select “Circle”.
- In the constructor type “filters = [new DropShadowFilter()];”
- On the next line type “addEventListener(” and press Ctrl-Alt-Space (this enables autocompletion for all available classes, not just the imported ones). Start typing “MouseEvent” but hit Enter as soon as you see it selected. Complete the statement with “.CLICK, onClick);”
- Move your cursor back onto the word “onClick”, press Ctrl-Shift-1 and hit Enter.
- Inside the generated event handler add the code: x += 10;
- Flip back to the Main class and change:
var circle:Circle = new Circle();
var circle:ReactiveCircle = new ReactiveCircle();
- Hit Ctrl-Enter.