Begining Flash Game Programming and ActionScript Programming Part 2 ALTERNATIVE (FOR MAC OR LINUX USERS): Downloading and Setting Up Eclipse (with the flash builder plugin) and Compiling Your First Program

Who This is For

This post is primarily for anyone that has to use Eclipse for actionscript programming, which is primarily for Mac, Linux, or even PC users who would rather use the eclipse platform.

FlashDevelop is only supported in windows (programmed using C#), so if using a Mac or Linux, you would have to use Eclipse with the Flash Builder plugin, or the Flash Builder, or for Mac users, code in the Flash IDE (CS3, CS4, CS5, ect).

Continuing

In the previous section, I listed pros and cons of creating games in ActionScript, as well as useful terms you may encounter when programming in ActionScript.

In this section, we will download and install Eclipse (with the Flash Builder Plugin), and create our first program.

(NOTE: I installed using windows, but using a Mac or Linux should be something somewhat similar – I’ll later try to borrow a Mac, and install Ubuntu to have screen shots from them as well)

Downloading and Installing Eclipse and the Flash Builder Plugin

Go to: https://www.adobe.com/cfusion/tdrc/index.cfm?product=flash_builder and download the ‘English | Eclipse Plugin for:’ whatever your system is.

You’ll have to create an Adobe ID to to be able to download anything from their site.

Next, run it and install it to somewhere on your computer (the default is fine, or install it to ‘C:\Eclipse_with_FB’.

Once it finishes installing, you should have a link start up Eclipse with the flash Builder Plugin, or you can start it up by going to the folder: ‘eclipse-host-distro’ and running ‘eclipse.exe’.

It will ask you for what workspace you want to use- I just created a sub folder in the folder where I installed Eclipse with the FlashBuilder Plugin named ‘WorkSpace’.

Once it starts up, go to ‘File->New Project’, double click ‘Flash Builder’ and double click ‘ActionScript Project’.

Type in a project Name of ‘FirstGame’, and click ‘Finish’. It will ask you if you want to change to the ‘Flash Perspective’, so click ‘Yes’.

You’ll get a new window with a tab in the center of the screen called “FirstGame.as”. Add the line of code below:

package
{
	import flash.display.Sprite;
	/*
	@author Chris
	*/
	public class FirstGame extends Sprite
	{
		public function FirstGame()
		{
			//this will output to the "Console" window below by ASDoc
			trace("this is my first game");
		}
	}
}

Now run/build and compile your program (F11 or click on the green ‘Play’ button under the ‘Navigate’ Menu on the top). Run it as a web application, and it will open a new webpage with a blank, white window.

But if you look in the Eclipse Window, under ‘Console’ on the bottom, you’ll see that it ‘traced’ out the first column!

This compiles the code in that file into a swf file and places it in your folders ‘bin-debug’ folder.

Trace is used to ‘debug’ your program- you can output text, variable values, and can check to make sure you can see what is happening in your program.
The end user can’t see these outputs, it only shows up while running inside of Eclipse.

Commenting

When you want to make a note in your code, but don’t want it to affect your program, you use commenting.

There are two ways to comment, the first is used to comment out the whole line. Use ‘//’, two forward slashes, and it will comment out everythign afterwards on that line.
You can see that being used above for ‘//this will output to the “Console” window below by ASDoc’. The two forward slashes are looked at by the compiler, realizes that it is not code that needs to be compiled, and skips the rest of the line.

The second way is able to comment out multiple lines, or a big block of code. Start it by using ‘/*’ (forward slash and a asterick), and end it using ‘*/’ (asterick and a forward slash).
An example of this can be seen above around the lines enclosing the ‘@author Chris’ block.

Comments are used to comment out a line that you want to temporarily remove, or to add a comment above a section so that you know what is going on, or so that other people can see easily human readable advice on what is happening in the program.

Scope (Created by Squiggly Brackets Generally)

Scope is an important programming concept to be aware of. Basically, it’s that variables created in certain places only exist in those places.
Such as vegemite was (lets say) created in Australia, and available in Australia, but the US has no access to it.

You’ll learn more about this later, but in general, if you create a variable inside of squiggly brackets, it only exists inside of the squiggly brackets.

Conclusion

Now you have setup Eclipse with the FlashBuilder Plugin, and have ran your first program, and traced out some text from it.

In the next section, we’ll start going into basic programming ideas that you need to know to be able to program in any language.

Bookmark the permalink.

7 Comments

  1. It’s all very well saying this is for Linux or Mac, but the link to the Flash builder plugin says nothing about a Linux version, making your page misleading. I came here because I googled “Linux flash game programming”, but it turns out this is of no use to Linux users.

    • Thanks for letting me know- Sorry about that, I hadn’t realized that they don’t make the plugin for Linux, and discontinued the FlashBuilder version!

      I’ll look into finding a way to code in Linux and update the article.

      In the mean time, I found this post on installing flashbuilder through wine in linux:

      http://blog.hexagonstar.com/setting-up-eclipse-for-flash-development/

      Again, sorry about that- eclipse works on all platforms, and I’m surprised that they don’t have the plugin only for Lniux.

      • No problem. Only just found the rest of your tutorials, and they’re very good, so thanks! By the way, in Linux the easiest solution appears to be to just call the mlmcx compiler (I think that’s the letters in the right order!) directly and do the coding in a regular text editor with syntax highlighting, like Vim or GEdit.

  2. Hiya! I have recently been trying to make video games for my Senior Project at school, when my mentor suggested this site.
    I’ve been going through it and everything is good but I ran into a problem. I was reading the page and then when I tried to actually run the program after adding what I was supposed to the Flashbuilder program said I needed Flash Player 11.3, I said okay and tried to download it. Then after following the steps I went to try to run the program, and it said I needed it again. This process happened like 5 times with no progress.
    Is there anything I can do? I’m currently using a Mac OS X 10.5.8.

    • You can try downloading the DEBUG flash player plugin from here:
      http://www.adobe.com/support/flashplayer/downloads.html

      And see if it installs that way.

      To check to make sure it is the debug version, after installing, go to youtube/ some other flash site, right click on a flash video, and it should say that it is the flash player debug version.

      Also, maybe you’re on a school computer that doesn’t allow you to install software?

      You can also try to look for an older version of FlashBuilder (I am using FlashBuilder4) that might not require as updated a version of flash player.

      Hope that helps!

      • Okay I tried to download the Macintosh 11.3 Plugin Content Debuger.DMG (Wow that is a mouthful) and it downloaded just fine, but when it actually finished and offered to install the Debugger, the program would automatically quit within a few seconds of it loading.
        Is there anyway to fix that?

  3. Hi Chris,

    First off wanted to thank you for creating such an easy to read well laid out tutorial, it is much appreciated!! Having said that I am experiencing a problem where I have no console tab along the bottom. I have all the regular tabs i.e. problems, data/services, network monitor, ASDoc, but console does not show up next to it. Any idea what the problem may be or how I may go about solving this? Thanks very much in advance!

    -Samuel

Leave a Reply

Your email address will not be published. Required fields are marked *