ActionScript 3 Hello World using Eclipse on OS X
July 1st, 2006Here are some quick steps to compiling a simple actionscript 3 swf using Eclipse. This should work using any OS although you would probably need to change the ant build file to use mxmlc.exe if on Windows.
1. Download the Flex SDK from here
2. Move the downloaded files to /Developer/flex_sdk
3. Create a simple project in Eclipse
4. Add new file to the project and name it “build.xml”
5. Add this code to the build.xml file:
1 2 3 4 5 6 7 8 | < ?xml version="1.0" ?> <project name="dar" default="build" basedir="."> <target name="build"> <exec dir="." failonerror="true" executable="/Developer/flex_sdk/bin/mxmlc"> <arg line="HelloWorld.as" /> </exec> </target> </project> |
6. Add a new file to the project and name it HelloWorld.as
7. Add this code to HelloWorld.as
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | package { import flash.display.MovieClip; import flash.text.TextField; public class HelloWorld extends MovieClip { public function HelloWorld() { var helloDisplay:TextField = new TextField(); helloDisplay.text = "Hello World"; addChild(helloDisplay); } } } |
8. Right click on build.xml and run it has ant build 1. Right click on file -> Run As -> 1 Ant Build
9. Right click on the project folder and select refresh. A file named HelloWorld.swf should be added.
10. Open the swf and watch the hello world goodness be shown.
March 23rd, 2007 at 5:04 pm
Thank you for making this clear. I keep reading about the “Free” flex SDK, but when you try to find out how to use it “free” there is not much documentation. This is a great snippet of educational code. THANK YOU!
April 24th, 2007 at 1:23 am
Thanks for this introduction. I’m currently exploring whether I should buy Flex Builder or just use Eclipse with some addons. I don’t really need the graphical GUI editor from Flex builder but I would want to debug my applications. Is that possible without Flex builder?
Thanks,
Mark
April 24th, 2007 at 11:57 pm
John:
Glad I could help and thanks for the feedback.
Mark:
You can debug your apps without buying flex builder. All of the compile error data will show up in eclipse when you compile. I used only the SDK for a while but finaly broke down and baught Flex 2. I’m very happy with the purchase. I spend much less time getting tools to work and playing with different eclipse plugins.
February 16th, 2009 at 10:34 am
Hey thanks for that. It was amazing.
Do you know if there’s anyway to get eclipse to highlight as3 syntax?
February 22nd, 2009 at 11:17 am
Adrian: There is AXDT ( http://axdt.org/ ) but I have not used it
August 28th, 2009 at 2:57 am
Very simple and excellent post, thanks.
How about Eclipse plugins? i note that there is a lack of the kind of control you can have for instance on php or c++ at the moment, and actionscript3 is far from supported…
August 28th, 2009 at 3:01 am
(sorry: i note that the previous comment was in the direction of an answer to my quest – thanks also to Aaron, then