Pages

Saturday, 4 December 2010

Compiling Flash from GEDIT

In the previous post I discussed an option for developing flash on Linux, using the free flex sdk, and free software. The main problem I found was that every time I wanted to compile and run a file, I had to type some commands in the terminal. I'm pretty lazy when it comes to programming and I'm sure most of you agree that it helps to get everything working as fast as possible.

To solve the issue I wrote a simple shell script which compiles and runs .as files, just like adobe flash does. This tutorial is for Linux users, if you're using windows I'd suggest using something like flashDevelop, which should do all of this for you anyway, if you're using Mac OS and can run Gedit from the terminal, it is an option but probable isn't ideal.

So first off, if you haven't got it yet install Gedit and follow my previous tutorial  at:

http://experimentalized.blogspot.com/2010/11/developing-flash-on-linux.html.

Once everything is set up head into Gedit and go to Menu > Edit > Preferences > Plugins and enable the "External Tools" plugin. If you don't have it you'll have to install it.

Exit Preferences and go to Menu > Tools > Manage External Tools...

Click the icon with a green +, to create your own 'tool'. The idea is that when you run the tool, a shell script runs mxmlc on your currently open document, and then opens the generated swf in the flash debug player.

In your new tool copy and paste the following
#!/bin/sh

EHOME=`echo $HOME | sed "s/#/\#/"`
DIR=$GEDIT_CURRENT_DOCUMENT_DIR
FILE=$GEDIT_CURRENT_DOCUMENT_NAME
EXT='swf'

echo "Compiling: " $GEDIT_CURRENT_DOCUMENT_PATH
echo '--------------------'

SWF=${FILE%as}${EXT}

cd ${DIR%${FILE}} > /dev/stderr

export PATH=PATH_TO_FLEX_SDK/bin:$PATH
mxmlc ${FILE}
gnome-open ${SWF}
replacing PATH_TO_FLEX_SDK with the complete path to your flex sdk (which you may have set up in the previous tutorial). If you haven't installed gnome-open use sudo apt-get install gnome-open in a terminal window.

You can set up a shortcut key to run the script. Then go back to your project class and run the command! If everything has worked you should see a window with your newly compiled swf running inside it!

There are a few problems with the script currently. Firstly the mxmlc compiler compiles to your src directory (wherever the actionscript file is). Second, there is still no debugging, which is a real shame. Gedit allows stdout to be displayed in the editor, so I am thinking of a way of displaying trace arguments right in Gedit. This would be an ideal solution to free and simple flash editing.

Here are some images showing Gedit compiling flash:


Monday, 22 November 2010

Developing Flash on Linux

I recently bought a new net-book, and having no patience whatsoever with Windows 7 Starter, I decided to install Ubuntu. The OS works fantastically with only 1Gb of RAM and as a first time Linux user I was really impressed with the ease of use and customisability of Ubuntu. Clearly as a flash developer I needed a way to develop flash, to at least a basic level (I wasn't after full debugging or any fancy features, just a way to compile some apps and to allow me to work on the train or in front of the TV)!

I decided to keep it simple; just a text editor with command-line compiling and testing.

So here is how I did it:

1. Install the flex sdk:

The free SDK is downloadable from adobe ( http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4 ), I downloaded 4.5 to try out some of the new features, but you can choose the build that meets your requirements. Save the library somewhere to your local disk (I chose /home/USER/developer/sdks/flex_sdk). The next step is to enable the terminal to access the executables in the flex_sdk which will build your programs.

Open a new terminal and type sudo nano ~/.bashrc (you may be asked to enter your password) and add the line:

export PATH=/home/USER/developer/sdks/flex_sdk/bin:$PATH

to your bashrc file. To test it has worked restart the terminal type "which mxmlc",  it should echo the path you just provided.

2. Download the Flash 10.1 Debugger for Linux:

Download the Debugger and install it using:

$ cd /tmp
$ wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
$ tar -zxvf install_flash_player_10_linux.tar.gz
$ cd install_flash_player_10_linux
$ ./flashplayer-installer


in your terminal.

Hopefully you'll have a functioning debugger now. Check it works by finding an swf, setting all swfs to open with the flash player, and run gnome-open file.swf, and the debugger should open in the flash player.

Failing this just use the flash for Firefox plugin.

3. Install AS3 and MXML language files for Gedit:

If you don't have Gedit, get it, its a great little text editor, and for me at least it does everything I need to (at least for editing AS3 files). Download the MXML and AS3 files from http://conic.se/blog/posts/8/ and copy them into ~/.local/share/gtksourceview-2.0/language-specs/. When you run Gedit you should be able to switch to the correct syntax highlighting for each language.


Finally put all three together. Create a directory containing the actionscript library you want to compile, and in your command line run mxmlc test.as. If you've followed the steps you should have created an swf. Finally run the swf using gnome-open test.swf.

Here are a few screenshots of the system in action:




 Good luck developing AS3 in Linux

Monday, 1 November 2010

Some Beautiful Transparency Renders in ASTrace

My raytracing project has been on hold for a while as I have been fixing minor bugs and not really creating anything new. I am rewriting some features of the raytracer completely from scratch which will hopefully improve performance and clarity of the code. I will implement features such as bounding spheres for intersection tests, as well as possible octrees or similar to improve performance for large numbers of objects. Once the engine is working fully in flash I will port it to alchemy, and hopefully with those performance boosts the engine will be ready for distribution.

Here are a few renders showing transparency and reflection that I created last night. Both are the same scene with different sky boxes applied. You can download the full size images (2200 by 1600px) by right clicking and saving as: