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 2 SDK from here
2. Move the downloaded files to /Developer/flex_sdk_2
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:
<project name="dar" default="build" basedir=".">
<target name="build">
<exec dir="." failonerror="true" executable="/Developer/flex_sdk_2/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
{
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.