Once I thought Adobe Flash CS5 was the only one way to write ActionScript 3.0 programs. Well, it is not true, but I didn’t know that. I’m a programmer and my profession is not drawing and animating things, I’m working with alphabets and text editors. I tried the trial version of Adobe Flash CS5 and it was a torture. It was completely inconvenient. Why? Because it was designed for writing short scripts which could be attached to dozens of drawings and animated characters, and that’s why this software is almost unusable if you want to do the opposite. Besides it is expensive. (Or at least in those days when I wanted to buy it it seemed so expensive to me like a gold bar). Using an illegal copy of Adobe Flash CS5 to write programs is something like stealing a Lamborghini to transport pigs to the market. Maybe you think that Lamborghini is a cool car and using a cool car must be cool, but the inappropriate usage reveals that you are an amateur.
Thank God for you I had good luck, I discovered FlashDevelop. (I found the idea on Stack Overflow, of course: http://stackoverflow.com/questions/5418058/free-flex-ides.) Wow, it was much better. FlashDevelop is a customized Eclipse, so if you like IDE then it is exactly what you need. At least it dosn’t seem like GIMP (Flash CS5 does) and you start to feel yourself like a programmer immediately if you start using it.
I thought I saw the whole picture, I had only the following choices if I wanted to develop AS3 programs:
- Using Adobe Flash CS5
- Using Flex IDE
- Using Flash Develop or FDT
Yesterday I read a forum topic (see here) and I discovered that there was also a fourth alternative and likely it is the best way for a weird guy like me to write AS3 programs. Flex SDK contains a platform independent AS3 compiler (mxmlc), and that allows you to write AS3 program with your favourite text editor. (VI or Emacs, that is the question.) It doesn’t sound complicated, I tried it, it worked, and I wrote my own tutorial about it. So, how to write and compile your own AS3 project under Ubuntu linux using VI, gentle reader, just follow the following steps:
[Prepare] Suppose you have a brand new Ubuntu Linux (12.10 in these days) and you don’t have a Java JDK. If you have Java JDK, just omit the second step. And etcetera.
[Install Java JDK] I didn’t want to struggle installing the newest Java JDK, because it was meaningless to me. Currently I don’t have enough time to develop Java programs on my own machine. (Because I want to develop an AS3+Box2D platform game engine in my free time or something like that.) So I installed an older Java JDK using the synaptic package manager.
sudo apt-get install synaptic sudo synaptic
And after than, I installed the package oracle-java6-installer with only a simple mouseclick.
[Download and unzip Flex SDK] I downloaded the newest Flex SDK (http://www.adobe.com/devnet/flex/flex-sdk-download.html), and I unzipped it into the directory /opt/flex_sdk_4.6. I used unzip and sudo, because writing anything into /opt is not allowed for non-super users.
[Set PATH] After than I set the PATH. I used Thomas Deuling’s tutorial. First I just edited the good old .bashrc:
Then I added the following line to that:
The next best thing that the AS3 compiler works after these steps, if you did the same steps like me, then just try this (according to Thomas Deuling’s tutorial again):
source ~/.bashrc mxmlc -version
And you will see some kind of magic:
Version 4.6.0 build 23201
The compiler reacts, so it works. Do you feel that you can compile your AS3 project under your Ubuntu Linux without any kind of IDE? I hope you feel the sound of music.
[Create a project template (or templates)] It is pretty meticulous to write a program from zero and it is also meaningless in the most of cases. For example, I’m sure if I develop anything in AS3 then it uses embedded images and embedded sounds, and I don’t want to code the necessary classes again and again (because DRY=don’t repeat yourself). That’s why I wrote the template project SimpleAS3Project. I coded also a small automake script which allows to compile/delete the swf file with typing make/make clean. I’m sure I will write more templates later (Box2D project, project with animated gif files, etc.), but one template is enough for testing.
[Set syntax highlighting in vim] First, download the file actionscript.vim. Then copy it into the directory /usr/share/vim/vimcurrent/syntax with the following commands:
sudo mv actionscript.vim /usr/share/vim/vimcurrent/syntax
Now the file is at its place, but it doesn’t work yet because first we need to set it in the file filetype.vim, so use the following command:
sudo vim /usr/share/vim/vim73/filetype.vim
and add the following lines to this file:
" ActionScript au BufNewFile,BufRead *.as setf as
After than, vim will use syntax highlighting on as files automatically.
- Install completed. Enjoy it!