Lean Out Your ActionScript Imports

by Kyle Hayes on February 7th, 2008

I have been working on a new Flex application at work lately which I am pretty excited about. Not only has it received a lot of positive attention, but I also get to learn how to build a Flex application that is to be using a PHP middle-tier. Luckily for me, I do have experience with PHP, plus there seems to be some great resources on the topic.

Anyway, the application is being programmed with the help of the Cairngorm micro-architecture and as such, there is a lot of copying and pasting of files as I create new commands, events, and delegates. One thing that has bugged me in the past about doing this, is figuring out which import statements belong in the newly created class and which don’t. Many a times, I just didn’t even bother. That has now changed, now that I discovered an easy, automagic way of doing so.

Knowing that Eclipse always has some gems hidden in the right-click context menus, I perused them to see if there was anything about import statements. Lo and behold, if you right-click on any of the lines that contain import statements, and go to the submenu “Source”, there is an option called “Organize Imports” (Or my preference: [Mac] Command + Shift + O, [PC] Ctrl + Shift + O). Not only does it actually organize your import statements by package alphabetically (starting with the root package), but it also eliminates any import statements that you do not need in that class. Pretty neat!

Some features I would like to see added to this:

  1. Add statements that are required
  2. Combine multiple import statements from the target package using wildcard (*) (Perhaps it could be defined in preferences, how many should be considered before it combines)
Popular Posts

From Flex

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS