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:


4 comments:

  1. I deleted my first comment cause it was an error.
    So for flex users who wants to compile mxml files just add a new tool, copy and paste the script and change :
    SWF=${FILE%as}${EXT}
    by
    SWF=${FILE%mxml}${EXT}

    Once again nice article !
    Thanx

    ReplyDelete
  2. Thanks for that Aries!

    Glad you found it useful, cheers

    Sam

    ReplyDelete
  3. You know how to involve a reader and increase his curiosity to read more.
    ----
    play game jogos online gratis online and play game unblocked games

    ReplyDelete
  4. The Casino, Restaurants | DRMCD
    Visit 안성 출장안마 our luxurious gaming floor and the ultimate dining destination for 화성 출장마사지 fun and relaxation 충청남도 출장마사지 at DRMCD. Choose from over 아산 출장안마 30 award-winning restaurants in your city, our 춘천 출장샵 signature

    ReplyDelete