
How-to: Building AS3 projects on Linux (edit: and MacOS)
Hey everyone!
I just wanted to share how you can compile your FlashDevelop projects under Linux.
No virtual machine is required. I am using Ubuntu 10.10 x64, but it should work fine on other distributions, maybe with slight modifications.
Copy this script, open a terminal (Ctrl+Alt+T) and paste (Ctrl+Shift+V)
Code:
sudo apt-get install mono-runtime
wget http://www.eclecticdesignstudio.com/code/flashdevelop/fdbuild.zip
sudo unzip fdbuild.zip -d /opt/fdbuild
sudo chmod 755 /opt/fdbuild/fdbuild.exe
sudo chmod 755 /opt/fdbuild/fdbuild.sh
wget http://fpdownload.adobe.com/pub/flex/sdk/builds/flex4/flex_sdk_4.1.0.16076.zip
sudo unzip flex_sdk_4.1.0.16076.zip -d /opt/FlexSDK
sudo chmod -R 755 /opt/FlexSDK
sudo gzip -dc /opt/FlexSDK/runtimes/player/10.1/lnx/flashplayerdebugger.tar.gz | tar xf -
sudo cp flashplayerdebugger /usr/bin/flashplayerdebugger
sudo chmod 755 /usr/bin/flashplayerdebugger
rm fdbuild.zip
rm flex_sdk_4.1.0.16076.zip
rm flashplayerdebugger
This will download Mono, FDBuild, the FlexSDK and extract the standalone player for viewing SWF files.
To use it, you can either call FDBuild directly by running "mono /opt/fdbuild/fdbuild.exe" from a terminal, or you can use the shell script I have provided.
The shell script gives FDBuild the path to the Flex SDK, and can also be edited to support any global classpaths you may have. There is already a blank "-cp" argument to help you get started. The script currently accepts two arguments: the path to the project file you wish to compile, and the path to the output SWF so it can launch it after compiling
Code:
. /opt/fdbuild/fdbuild.sh "path/to/my/Project File.as3proj" "path/to/my/Output File.swf"
The script currently runs using sudo, since Java (on my system) complains about not being able to find jar files when it is run as a normal user. I'm not entirely sure why. This could also probably be a bit more elegant ... but I hope it is still helpful!
Feel free to share any suggestions you may have to improve the process. This currently does not run FCSH for faster compile times, and will still run the SWF if there are compiler errors. However, this should make it a lot easier to compile projects on Linux, even if you don't use FlashDevelop to edit the code.
UPDATE:Until we have a plugin or other application in Linux to create FlashDevelop projects for us, I have temporarily added a "template.as3proj" file to the FDBuild package which should help.
Code:
cd path/to/my/project/directory
cp /opt/fdbuild/template.as3proj project-name.as3proj
vim project-name.as3proj
You can copy out the template, then edit with gedit, vim, or whatever you prefer. You'll need to put in the relative path for where you want the SWF to be created (IE: "Export\MyProject.swf") and the relative path for where your document class is located (IE: "Source\com\my\project\MyProject.as")
UPDATE (2):I've just integrated Philippe's great "bonus" to the fdbuild.sh script, so now you can compile projects like so:
Code:
. /opt/fdbuild/fdbuild.sh "path/to/my/Project File.as3proj"
... and it will automatically pull the output SWF path from the project file in order to launch Flash Player.
If you already have the scripts installed, you can update to the latest version like this:
Code:
wget http://www.eclecticdesignstudio.com/code/flashdevelop/fdbuild.zip
sudo unzip fdbuild.zip -d /opt/fdbuild
sudo chmod 755 /opt/fdbuild/fdbuild.exe
sudo chmod 755 /opt/fdbuild/fdbuild.sh
sudo chmod -R 755 /opt/FlexSDK
rm fdbuild.zip