Thursday, August 10, 2006

Using The Flex 2 SDK with Flash Develop

I saw Keith Peter's blog post about using FlashDevelop and the Flex 2 SDK.

However, there is one problem; insects really bother me. Especially ants. So here's a way to use the Flex 2 SDK without those pesky ants getting in the way.

First you need to download all the files needed.

The new ASCompletion DLL
The Flex2 SDK
Flash 9 Intrinsic Class Files
Flash Build Plugin

Download and unzip the new ASCompletion DLL into the Flash Develop plugin folder. Unzip the Flex2 SDK into "C:\Program Files\Adobe" . Once that's complete you'll need to download and unzip the Flash 9 Intrinsic class files into any folder you please (I recommend the base Flash Develop install folder). Finally, unzip the latest Flash Build plugin into the Flash Develop plugin folder.

With all this completed open up Flash Develop and create a new standard project. Flash Build may or may not ask you if you'd like to create a build file for this project. If it does press yes, if it doesn't it should have already created one called "flashbuild.xml" in the root folder for the project.

Once Flash Build has created the flashbuild.xml file double click on it to open it in flash develop. You will see a very nice GUI that will allow you to easily setup different builds for the project. Choose the ClassPath's item from the FlashBuild drop down list. You should see the default class paths there. However, in order to get Flash 9 functionality you need to add the AS3 Intrinsic classes that were unzipped earlier to the global class path. In my case this was "C:\Program Files\FlashDevelop\AS3_intrinsic_classes". Once that is done it's time to setup the actual build.

You should see an item in the FlashBuild list called "Build 1" select this item and on the right a new set of controls will appear. Choose a build name, I chose "AS3 Build", very original. Once that is done right click on the newly named build and choose "Add Flex2 Build".

Choose the newly created Flex 2 build by clicking on it. A new set of options will appear in the right hand pane with a few tabs: Quick Start, MetaData, and Advanced. If not already selected, choose the Quick Start tab. Once the QuickStart tab is selected add the main class file as the "Input MXML/AS". In my case, because I'm using the standard project template, this was "./classes/".

Alright, now you're ready to test the build. From the top menu choose the Build drop down. From that choose the Build item and then "AS3 Build" or whatever your build's name was. If all went successfully it should output something like below in the output window.

Running process: C:\Documents and Settings\Sam\My Documents\New Project\Flashbuild.bat 
"C:\Program Files\Adobe\Flex2SDK\bin\mxmlc.exe" "classes/" -accessible=false -allow-source-path-overlap=false -as3=true -benchmark=false -debug=false -default-background-color 13421823 -default-frame-rate 24 -es=false -generate-frame-loader=false -headless-server=true -incremental=false -keep-generated-actionscript=false -lazy-init=false -optimize=false -show-actionscript-warnings=true -show-binding-warnings=true -show-deprecation-warnings=true -strict=true -use-network=true -verbose-stacktraces=false -warnings=true
Loading configuration file C:\Program Files\Adobe\Flex2SDK\frameworks\flex-config.xml
C:\Documents and Settings\Sam\My Documents\New Project\classes\Main.swf (494 bytes)

Make sure your file is AS3 compliant. The bare bones should look like this:

public class Main{

public static function main():void{


Try to build your project again. If all goes well it should work flawlessly.

Congratulations on your ant free build.