14 January 2008
[Update: This is an update on my post Complete starter guide for developing Flash projects using Eclipse/FDT. I've also decided to merge the follow up post Complete intermediate guide for developing Flash projects using Eclipse + FDT into this one updated post]
This post is aimed at beginner Actionscripters. It covers all the basics of setting up Eclipse and FDT environment to develop some kick-ass websites in a more structured Object Orientated approach. From managing workspaces to connecting with repositories, this document should be all-inclusive for any new Actionscripter who wants to start doing some serious Flash projects. If I missed something please feel free to comment or send it to me so I can update this post.
The Eclipse IDE consist of several graphical user interfaces. Each of these interfaces has a specific purpose. You can decide which interfaces to switch on and off depending on your development needs. The major break down is as follows:
The location where all your files will be created. Eclipse has a project explorer which is essentially your project folders & files. You can have multiple workspaces on your machine and switch between them as and when required.
This is basically all the interfaces you are looking at when launching Eclipse. As mentioned above you can personalise what you want to see. A perspective is a collection of graphical user interfaces, i.e. views. Similar to workspaces you can have multiple perspectives. The default is Java as Eclipse is primarily a Java development tool. Written in Java for Java.
After installing FDT, Eclipse should open up the Flash perspective by default. This is extremely powerful as I can setup different workspaces for different programming/scripting languages. I can keep all my Java projects together and similarly all my HTML and Flash projects respectively. Each workspace has its default perspective associated to it. I could have different language projects in the same Workspace and just switch the perspective as required. Later in this post I explain how I like to setup my workspace.
Views are the graphical user interfaces that make up each perspective. Views as with perspectives can be customised to the developer's needs. Each workspace remembers what views are in use and therefore you can have specific views for say your Java Perspective and also specific views for Flash. In Java I might not need the SWFViewer View so I can disable it. Similarly in the Flash Perspective I might not require the Junit View.
We use the following tools for our Actionscript projects:
There are two ways to install a plug-in for Eclipse. The first would be to copy the features and plug-ins folder manually from your plug-in download archive to the root of the installed eclipse location. The second would be to use the update site should one exist for the plug-in you want to install. An update site doesn't always exist as it depends on the author of the plug-in to create one. Basically as oppose to downloading the archive file for the plug-in you download it through the Eclipse interface wizard and Eclipse installs it in the correct location.
It is obviously much better to manage your plug-ins this way. I would advise you use this method always if available. It is entirely possible for you to remove the wrong files and that could have a severe impact on Eclipse itself. Although that is quite a serious warning it is not the end of the world. The good news is that as long as your workspace is in tact, i.e. no files are corrupt etc.; you should be able to install a new version of Eclipse without any problems and set the workspace to point to your old one.
Follow these easy steps to add a new update site:
Due to this you might want to install a plug-in that actually requires (dependant on) another plug-in and an error will appear in the dialog's white space as soon as you select the feature that you want to install. As far as I know this is common with older style plug-ins because creating plug-ins for Eclipse 3x has changed quite a bit since Eclipse 2x. However this does come down to the way the plug-in was created and there isn't much you can do without tracking down this dependency in order for your plug-in to be installed.
Click on Select Required if you are installing a plug-in while searching for Eclipse project updates. By default you should have 2 remote sites after installing Eclipse called Europa Projects updates or Europa Discovery Site. These sites contain updates for the Eclipse IDE and can also help solve some of these dependency issues. If you get an error while trying to install a feature click on Cancel and do the update process again except this time include the above mentioned update sites.
If this doesn't work try unchecking the Show the latest version of a feature only checkbox. Unchecking this will show all the versions available within this feature to show and there might be a previous version you can use.
Important note: For the purpose of this post you shouldn't get this dependency error. By installing the Classic Eclipse Europa IDE release and FDT3 you will have everything you need. The above solution is for future additions you might want to make to your development environment.
After Eclipse 3.3 there were some changes in the management of plug-ins. The steps below describes the latest version when this post was updated.
It is a good idea to have different workspaces for different clients. By doing this you reduce the amount of projects you have in one workspace as it can fill up quite quickly. Darren Schall has a post specifically about understanding the power of Eclipse workspaces. Having loads of projects in one single workspace can slow Eclipse down as FDT builds each project on start-up to give you any errors in your class files.
Alternatively if this is not how you like to work, then simply make use of "Working Sets". Working Sets are a quick and easy way to filter what is shown in your Project Explorer. There are a few ways of creating Working Sets but the easiest is to click on the little arrow with tool tip "View Menu" and choose "Select Working Set". With this window one can select, add or edit a new Working Set. Use the arrow button to select or deselect a working set.
It is important to know however that a working set will not filter quick search of resources using the Ctrl + Shift + R shortcut. Working Sets doesn't "close" a project it simply hides it. If you want to avoid resources appearing when using this shortcut from other projects in the workspace then you have to either close the other project or using different workspaces.
It's not really an issue but rather an adjustment that has to be made for FDT to fully function. When you download Eclipse the default memory allocation for Eclipse is 256Mb. For use with FDT we will have to change this to 512Mb or higher. Don't worry it's very straight forward:
That's it. Now Eclipse will use 512Mb memory and FDT will be able to fully function. Restart Eclipse and Voila!
Creating a flash project is a three part process. Choose a name for you project. Select the linked library you want to use. After successful creation assign a source folder where your classes will reside.
There is no fundamental difference. An SWC is a collection of classes, i.e. a compiled set of classes. A linked library is reference to a collection of classes that is not compiled but can also be an SWC. An SWC can be setup to be a linked library. This was used in MX days to create components and to distribute a set of classes. Now it is an acceptable format for distributing components and a collection of classes.
This is quite a hard one for lots of people as the UI doesn't seem to be very user friendly. But I will try and explain how the set up works. It is worth mentioning that FDT 4 has some great improvements on this front. So this is more for people like me who are still using FDT3.
When FDT is installed, the core SDK is included. This will be unzipped the first time you run Eclipse with FDT installed. The core libraries are managed in a two part process. The set up of a "Path Variable" and the set up of the Core Library itself. The Path Variable is a variable that points to the destination of the Flex SDK. A Core Library will reference this Path Variable. To see what I'm talking about do the following:
If we were to install a new Core Library like Flex 4, we would need to do the following (FDT 3):
Now we have successfully added a new Core Library however we haven't associated it with any projects.
To change the library an existing project uses do the following:
Upon launching Eclipse after successfully installing and creating FDT projects, FDT should automatically build the workspace. This means it checking the codes for errors and warnings and displaying them. This also happens when you save a file. You can clean a project and then re-build it, i.e. refresh FDT if you need to force FDT to re-evaluate your classes. Sometimes the last state of errors are displayed if you open a file and only updates when you alter and save the file. This doesn't happen too often but sometimes can.
Building projects automatically can be by simply deselecting the Build Automatically option in the menu under Projects. Similarly cleaning a project can be done here as well.
Tired of typing all those getters and setters? Maybe you use Singeltons often or have a custom Log class. There is no reason to do al that typing. FDT has some built-in templates but here is how you add your own custom ones.
Adding a getter & setter template for AS3
Pattern:
public function get ${var}():${type}
{
return _${var};
}
public function set ${var}( value:${type} ):void
{
_${var} = value;
}
I got 99 problems... Well, there's no need for 99 as you can switch them off. Apart from the strict compiler setting, you can actually set what type of errors you want FDT to make visible. Now you may wonder why you would want to do this but in some cases you might have an AS2 and AS3 project running in the same Workspace, and for AS2 you want to allow untyped member access as that is what you are used to. Seeing all these errors while you project still compiles is a bit annoying. Go ahead. Turn them off.
The local history has definitely saved a few asses in its day. Eclipse keeps an internal history of all modifications made to your files. Obviously this is not as persistent as a version control repository. Nonetheless having this always available is an incredibly strong feature for any development environment. To set the preferences for the local history:
Probably the coolest feature of Eclipse. Comparing two files with the differences highlighted. The Compare With view allows you to compare files from the local history, with a specific revision in the version control repository or with another file in your project. Nothing compares.
A great advantage of coding with FDT is that all your classes are external, which means all files are text files. Search functionality is ever present in all Actionscript IDE's, although I have yet to see any IDE match Eclipse. A search feature is vital with maintenance, especially if you don't know the project. Apart from the normal Find and replace within a single file, Eclipse has an advanced search that will make maintenance and updating a breeze. Searching for a single file:
To search within a file:
This feature is not only useful for solo Actionscripters but also for teams to manage what still needs to be done on a project. By using comments and typing the words "TODO:", the comment is added to a pool of comments which can be seen by the TODO view. This is especially useful for all those mental notes a developer has. Imagine writing thoughts down but for everyone to see. Anyone who opens the project can see what is on the TODO list. This very often helps with maintenance on tight deadline projects where shortcuts or amends take precedence of a solid foundation solution. By making a note of these hacks or quick fixes using TODO it will add to the transparency of your code which is imperative when working in a greater than one environment.
Example: //TODO: Optimise the method to load data from XML
To see all the TODO's in a project:
Very similar to TODO's, bookmarks are exactly what the name suggests. A great way to make notes of where important functionality resides within classes. Larger projects can be very daunting but breaking things down and making notes without touching the class itself is priceless. That would be the advantage over TODO's. It doesn't mean you need to alter anything in the code. As an observer you can make notes about code snippets that are of importance to you.
To see all bookmarks:
In Eclipse all version control software work in the same way. Everything happens from the Team view and is mostly accessed through the context menu.
Below are a few basic steps for setting up Subversion with Eclipse
If the SVN Repository view is not open then open it like so
Checking out a project is very simple. The SVN Repository View introduces a nice way for managing your SVN repos:
A few simple steps and you have added an existing project to Subversion:
[Update: Not sure if anyone still uses this Eclipse plug-in but I left this legacy set up in just in case]
[Update: I'm leaving this legacy set up as part of this updated post as I'm sure there might be some people who still use AS2]
So a complaint I hear from a lot of developers are that FDT and Eclipse is great however you need to constantly jump between the Eclipse IDE and the Flash IDE. For an AS2 project this is absolutely true but there are some tweaks you can add to your Eclipse environment to improve this workflow. For AS3 projects you could use FDT to run your code without an FLA at all. You can create FLA libraries or use external assets and embed/load them at runtime and compile your project without requiring any FLA at all.
After this little tutorial you should be able to run your current application using the shortcut Ctrl+Enter as you would run "Test Movie" in the Flash IDE. This obviously only works once you have it setup.
After you have done this Ctrl+Enter will be a shortcut for the last run FDT Flash IDE configuration. So you can set up all you projects and run the one you are currently working on for the first time. There after you can use Ctrl + Enter. Very useful indeed.
Hopefully this post will help some people to get started with Eclipse and FDT. I know it took me along time to understand everything and I think a starter document like this would have been very handy. Well, sharing is caring. How cheesy is that?
I keep getting an "AST not built" message that prevent code hinting from working.
i agree. wez knows whats going on when it comes to FDT. cool new site too dude.
I agree with the previous comment, very comprehensive! However, I keep getting an "AST not built" message that prevent code hinting from working. What do you think might be causing this? Thanks! CKMBA
This is the best guide I found for developing Flash projects using Eclipse/FDT.
Sincerely,