Wednesday, September 16, 2009

Flash development on Linux (II)

Once you have set up your Flash / Flex development environment on your Linux box, you are ready to compile your first application.

Open Eclipse with the AXDT perspective

Create your first project. This is done under the menu item File -> new -> AXDT project.... Give a name to your project and select a directory (usually under the directory that you chose as your workspace).



After the creation of the project, you can start to add your source files. The compiler supports both kind of files: as3 (ActionScript) as well as .mxml files. We are going to compile a sample from the AXDT site.

Go to the menu and choose File -> new -> AS3 file



Choose the folder to store the source file (usually src). Optionally you can organise your code in packages. Using packages is optional but becomes more necessary as you project grows. Better being used to manage packages from the beginning. The sources will be placed in a subdirectory tree structure according to the package structure. Finally, give a name to your source file: As in many other OOP languages, the file name must be the same as the name of the class defined in such source file.

After the creation of the source file, write down (or copy + paste) the file contents. At this point, your environment should look more or less like this:



Once created and saved your source file, you can compile it. Just click on the menu item Run -> Run As -> Compile and Open a SWF File. You will see some options to configure the compiler but do not worry about such options right now. You can maintain the default values.



If everything has gone right, you will see your Flash application running on the Eclipse IDE . The swf file created will be placed on the target location (default is deploy), so you can copy such file and publish it on your website.

13 comments:

Anonymous said...

Great !! It works. Thank you.

Anonymous said...

great - works pretty good. Was unable to get a swf to show up in the native window. the compiled swf works fine when opened in firefox however. thanks!

steev said...

thanks! Great tutorial

Anonymous said...

The .swf did not run within my Eclipse container either, but everything else worked just fine :)

Rikki said...

I just added my solution to getting the SWF to display within Eclipse here http://axdt.org/wiki/GuideViewer

My steps were for Mac OSX, though I'm sure they can be adapted for Linux (and Windows). Drop me a line if you need help figuring it out.

I found the problem was that I had an old version of Mozilla XULrunner and that once I updated it, I needed to copy the Flash plugin into the appropriate XULrunner directory.

The steps are:
1. Remove all old versions of XUL runner: delete the /Library/Frameworks/XUL.framework directory (Reference)
2. Download the latest version of XULrunner from Mozilla XULrunner releases and install it (open the DMG and run the installer PKG)
3. Add the Flash player plugin to the XUL runner plugin directory. To do this:
(a) Copy Flash Player.plugin and flashplayer.xpt from /Library/Internet Plug-Ins
(b) Paste them into /Library/Frameworks/XUL.framework/Versions/X.X.X/plugins where X.X.X is the current version number (e.g. 1.9.2)
4. Restart Eclipse if necessary. Try running one of your compiled SWFs within Eclipse. It should work now!

macelee said...

For Linux, make sure xulrunner package and flash plugin are installed. Then make a symbolic link at the 'plugins' directory of your xulrunner installation - it is /usr/lib/xulrunner-1.9.1/plugins on my system. From there, do ln -s /usr/lib/flash-plugin/libflashplayer.so libflashplayer.so. Then restart eclipse and the SWFs should work within it.

Rikki said...

I found that on my Mac, once an SWF has been run within Eclipse, a portion of the left edge of the editor window gets erroneously drawn over the middle of the editor, obscuring my code! It only disappears if I restart Eclipse (and only until I run an SWF again!) :(

Has anyone else had this occur to them (on Linux or Mac)? If so, did you work out a fix?

Anonymous said...

nice tutorial!

benjamin said...

Hi there, great stuff!! I was looking forward to learn Flex, but using Windows was out of the question for me.
Do you know if it's possible to have the Components view in Design mode on Eclipse too?
And can Eclipse auto-fill or make suggestions (to some degree) like Flex Builder?

Thanks :)

josean said...

Hi Benjamin,

As far as I know, this is not possible using this kind of IDE.

Anonymous said...

Hi Rikki and MaceLee,

Could you possibly assist me with making the SWF appear in the native window? I've been scanning the net and going through the SWT docs for days to no avail, I just get a white window. I tried what you both advised, but still just a while window. Help and some tips will be appreciated.

Unknown said...

how to resolve embed path problem?

Rikki said...

Hi Anonymous,

I've long since given up on this as a method of Flash development. It was too much hard work. I tried FlashDevelop in a Windows VM for a while, but again it was prohibitive.

Now Flash seems to be out of favour, so I'm moving my efforts to HTML5, which just needs a text editor and a browser, which works on every platform!

Cheers,
Rikki