Programming in Actionscript 3 for Free

Programming in Actionscript 3 for Free
Difficulty: Easy
Description: Get everything you need to program in AS3 then make sure it all works.
Author: jrdnllrd; Date Added: 2009-09-06; Views: 26643
Alright so you want to learn Actionscript 3 but don't want to spend hundreds of dollars on Flash. There are two options for you in that case. Break copyright laws and get an illegal version or follow this tutorial so you can learn Actionscript 3 for free legally. By the end of this tutorial you will have everything you need to get started and you will have learned how to build and run some code.


To program in AS3 for free you are going to need to download a few things. You need an AS3 compiler which you can get from Adobe and is part of the Flex SDK. Download the FREE Flex SDK and extract it somewhere on your computer.

You will also need the Java 1.6 runtime (JRE). You can check what version you have by going to "Start -> Run", typing "cmd"(without quotes) and hitting enter or clicking ok, and then typing "java -version"(without quotes).

Now we will download a free IDE (Integrated Development Environment). It is not required but it is a lot easier to program in then Notepad and will allow you to build and run your project from within it. We will use FlashDevelop. You will find the latest release at the top right of the page.

You will also need Microsoft.NET Runtime 2.0 for FlashDevelop to install. If you're not sure if you have it or not, you can try to run the FlashDevelop installer and you will get error message if you don't have it.

The last things you need are Flash Player content debuggers. These, unlike your regular flash player, will output trace() functions and any runtime errors. The Flash Player 10 Projector content debugger is for the external player while the Flash Player 10 ActiveX control content debugger (for IE) is for the embedded SWF player. I suggest getting both even though we will use the external player as it is more stable. NOTE: The Flash Player 10 Projector download is not an installer. Just save it somewhere.

Configure FlashDevelop

Once everything is installed open up FlashDevelop. Then go to "Tools -> Program Settings (F10)". In the box on the left under "Plugins" click on AS3Context. Now on the right, under "Language" find the "Flex SDK Location" row and to the right of it click on the ellipsis (...) and choose the folder where the Flex SDK has been extracted to. Next, in the box on the left again, click "FlashViewer". Click on the ellipsis (...) next to "External Player Path" and find the Flash Player 10 Projector content debugger you downloaded earlier. Then make sure that the "Movie Display Style" is set to "External".


Now we can test to make sure everything is working the way it should. Go to "Project -> New Project..." then under ActionScript 3 choose "AS3 Project". Name it whatever you like (I used FDtest) then check the box that says "create directory for project", this way all your project files will be in one folder together. In the right panel you should have the Project Manager, and you should see all the files in your new project. Under the "src" folder double-click on "" to open it. Once it's open you should some code already in there. I want you to replace it all with this code (it only adds one line):
	import flash.display.Sprite;
	 * ...
	 * @author ...
	public class Main extends Sprite 
		public function Main():void 
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		private function init(e:Event = null):void 
			removeEventListener(Event.ADDED_TO_STAGE, init);

I added the function trace. This will output the text in the parentheses into the output panel at the bottom of FlashDevelop.

It is useful for debugging as it allows you to see the values of variables during runtime. And this is also why we needed to download the content debugger flash players. Now go to "Project -> Test Movie (F5)". It will take a little while as it builds your project, then a blank window will open. Close that window then look in the output panel at the bottom of FlashDevelop.

If it doesn't build and you get an error like this "Exception: Could not locate libmxmlc.jar in Flex SDK. Please set the correct path to the Flex SDK in AS3Context plugin settings." you didn't choose the right folder for the Flex SDK. If it builds but you don't get a blank window then you didn't chose the right program for the external player. If the output panel doesn't say "Testing..." then scroll down in the panel. If it still doesn't say "Testing..." then make sure you are using the content debugger flash player.

And you're done!

Now that you have finished this tutorial you can find some tutorials to start learning AS3. I hope that this tutorial helped you in some way and maybe I helped an amazing programmer get started.

Tutorials to get started:

Emanuele Feronato's Blog
AS3: Main
Google Search