Using Actionscript 3 to develop Adobe Flash Content On Linux

linux-conf-128x128Because I installed Linux in my VMware and one of the feature of Adobe Flash is cross-platform, I tried to create the application which using Adobe FLEX 3.0 SDK to develop flex/flash under Linux. In fact it’s just a “hello actionscript 3″  instead “Hello,world!” known for every earthman. This article is not to introduce the skill of ActionScript 3, but how to use free Adobe FLEX 3.0 SDK development environment to build your flex/flash application under Linux. What you do is just following these steps, then you will see your Flash running under your Linux(Firefox). (Here is the Chinese Version of this tutorial posted on my Chinese blog)

1, Preparation and Requirement

・Install Adobe FLEX 3.0 SDK

Download the Adobe FLEX 3.0 SDK from http://www.adobe.com/go/flex3_sdk. Choose “I have read the Adobe Flex 3.0 SDK License, and by downloading the software listed below I agree to the terms of the agreement.” Then click ” Download the Flex 3.0 SDK for all Platforms.” See the following picture.

Adobe-Flex-3-Software-Development-Kit

Install after download to local. For example under the /tmp/flex:

$ cd /tmp/flex
$ unzip flex_sdk_3.zip

Then you will find SDK files under /tmp/flex/bin

・Install JDK

Generally when Linux installed, the JDK have installed at the same time. If not, you could visit Sun homepage to download and install it. Here we will skip this step.

2, Prepare the hello.as code for “Hello ActionScript3″

Use vi or your favorite editor to save following code as “hello.as”. Please pay attention the Capital and lowercase.

package {
    import flash.display.*;
    import flash.text.*;
    public class hello extends Sprite{
        public function hello (){
            var t:TextField = new TextField();
            t.text = "hello actionscript 3";
            t.width = 300;
            t.height = 200;
            t.x = 50;
            t.y = 20;
            addChild(t);
        }
    }
}

3, Compile

Type and run following command, the as source file will be compiled to swf file.

$ /tmp/flex/bin/mxmlc  hello.as

If success, you will find file hello.swf. Then type the following command directly.

$ firefox hello.swf

Do you see you own “hello actionscript 3″?

4, Create Makefile

Makefile(make) is an expert system that tracks which files have changed since the last time the project was built and invokes the compiler on only those source code files and their dependencies. Perhaps for the example in this article, makefile may can’t show its advantage. But for the big projects which have many source files, makefile will be a important role. When you modified AS source files, what you do is just run “make” command.Use vi or your favorite editor to save following code as Makefile:

MXMLC = /tmp/flex/bin/mxmlc
MFLAGS = 

TARGETS  = hello.swf

all: $(TARGETS)

clean:
	$(RM) $(TARGETS)

.SUFFIXES:	.as .swf
.as.swf:
	$(MXMLC) $(MFLAGS) $<

Then run following command

$ make

We will get the same result as run “/tmp/flex/bin/mxmlc hello.as”, you will see hello.as is compiled to hello.swf.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

RSS Feed   RSS Feed     Email Feed  Email Feed Follow us Follow us
You can leave a response, or trackback from your own site.

21 Responses to “Using Actionscript 3 to develop Adobe Flash Content On Linux”

  1. [...] ※Ref:Using Actionscript 3 to develop Adobe Flash Content On Linux [...]

  2. [...] previous article Using Actionscript 3 to develop Adobe Flash Content On Linux(Chinese Version), we have tried to use Adobe Flex 3.0 SDK developed “hello actionscript [...]

  3. [...] 3(Adobe FLEX 3.0 SDK)开发Adobe Flash应用(英文版本)中,我们尝试着在Linux的环境下,利用Adobe Flex 3.0 [...]

  4. [...] Using Actionscript 3 to develop Adobe Flash Content On Linux (4) [...]

  5. Good example, only heelo word, or all scritint an ide por linux ?
    Eclipse for Flex ?

  6. [...] 在文章Using Actionscript 3 to develop Adobe Flash Content On Linux中,非常详细的一步一步的说明了如何在Linux下开发Flash。我们知道,Flex允许通过XML和JavaScript编译成.SWF,利用SDK这是免费的,而对于Flex/Flash的GUI开发环境,则需要比较高昂的费用。已经有人将Flex SDK很好的整合到了Emacs中,当然你也可以整合到自己喜欢的Unix/Linux编辑器中,这是否是一件很Cool的事情?下面是一些很有用的资源,可以帮助我们做到这一点: [...]

  7. [...] article Using Actionscript 3 to develop Adobe Flash Content On Linux, we have introduced hwo to develop flash on Linux step by step. As you know, flex could compile to [...]

  8. [...] I’ve been wanting to get flex up and running in Ubuntu for yonks, so that I can get stuck into actionscript 3. Finally found a site that explains how to do it in small words for me (and, more importantly, doesn’t rely on files that no longer exist, lost to the gaping maw of the interwebs). [...]

  9. Vadim P. says:

    Good one, but why do you put it into /tmp? Doesn’t that place get cleared on every reboot?

  10. sp says:

    Better idea is to put it somewhere other then tmp like /usr/local or /opt then set your bashrc script to add the /bin directory to the PATH variable.

  11. dan says:

    Nice tutorial, this is exactly what I was looking for.

    Is there any chance you can expand on the make file aspect? An example where you have code in two or three actionscript files and you want to compile them into a single swf would be greatly appriciated.

    Thx.

  12. dan says:

    Nevermind. I see how it works now.

    Thanks again for the great tutorial.

  13. josean says:

    You can find here a detailed tutorial on setting an Eclipse based IDE for Flash development on Linux:
    http://netpatia.blogspot.com/2009/09/flash-development-on-linux.html

  14. spy says:

    thanks a LOT!!! very useful manual +) very easy and fast….

  15. boris says:

    Hi! I am a fervent command-line developer so I am always happy to see people promote it. I found that in Flex 4 you have to use extra command line switches to get it working, in particular:
    “-static-link-runtime-shared-libraries=true”
    and also “-debug=true” to see debug output. I’ve put more details on by blog: http://www.borisvanschooten.nl/blog/?p=26

  16. Jand Eich says:

    Just what i was looking for. Thanks a lot!

    If you plan on doing more tutorials, please keep ‘em simple, like this one was. I, and i believe i speak for a lot of people, can’t tolerate when a tutorial gets too long. All i want is to get my hands on the good bits, that’s it.

Leave a Reply