Organizing imports in Flex Builder 2

Today I was working on refactoring code of a large Flex application.

Many files contained lots of imports at the top. I was looking for a quick way to organize my imports.

I did vaguely remember that there was on an option somewhere to organize the imports, but couldn’t remember where to find it! Did all my right-clicks etc., but just couldnt’ see it.

I was almost about to move on, but then I found it!
In Flex Builder, click on Source > Organize Imports to organize imports alphabetically.

Even better, there is shortcut keys for it organizing imports.

On Windows: CTRL + Shift + o

On Mac: Apple + Shift + o.

Keep in mind that that imports can only be organized in this manner in Actionscript files only. (This will not work in MXML files.)
But overall, it works beautifully.

Simple Flex RSS Reader using Cairngorm

I recently wrote a sample Flex application — a simple Flex RSS Reader — using Cairngorm.

I find that learning Cairngorm is made easier by looking at simple applications like this one. And the one I wrote earlier — a simple contact manager.

When one looks at how Cairngorm is implemented across multiple applications, one starts seeing common patterns. And that is exactly the point of a framework like Cairngorm.

Learning the framework is made easier by the fact that there is a certain repeatability and consistency in the way a Cairngorm application is structured.

Download the application

I’ve also setup a Google Code project for the application.

Update (9 March 2011): The project has been moved to  GitHub.

Here are the instructions on how to install and setup the application.

Download and Unzip FlexRSSReader1.0.zip

This will create a subfolder: com (containing the Flex code for the application and Cairngorm 2.2 SWC)

Set up the app in Flex Builder

  • Create a new Flex project in Flex Builder.
  • Select “Basic”
  • Specify Project Name: FlexRSSReader and point it to the directory where you unzipped the source file.
  • Add the Cairngorm library — Cairngorm.swc — to the project by going to Project > Properties > Flex Build Path > Library Path (tab) > Add SWC. Select the Cairngorm.swc in /com/adobe/cairngorm directory.
  • Run the application and you should see the Flex RSS Reader load up in a browser.

Hope you find it useful. Please do drop me note if this helped you, or if you have any suggestions on how to improve it.

Unable to resolve a class for ResourceBundle: CairngormMessages

Today I was building an application using Cairngorm 2.2. All was going well and I was very happy with the progress I was making. But then, I started facing this error while compiling the application.

Unable to resolve a class for ResourceBundle: CairngormMessages

From the text of the error it appears that the locale-specific bundle for CairngormMessages is not available/visible.

I made sure that the “locale” folder was available off the root of the project, and that the compiler was using the correct locale setting.

But I found an interim solution to the issue — using Cairngorm.swc, rather than the actual source of Cairngorm (which I was using) makes the error goes away.

So, for now I’m on my way by using Cairngorm.swc. But I still need to figure out why the error occurs in the first place.

Any thoughts?

Introduction to Flex — Presentation at Web on the Piste

This morning I gave a presentation on “Introduction to Flex” at Web on the Piste at Queenstown, New Zealand.

It went off quite well — at least that is what I hear from the response to the presentation.

I realized that for an hour-long presentation about 20 slides is the maximum, especially when one is going to show code as well.

I’m attaching a PDF of the presentationwith this blog entry.

Also, I demoed a small RSS reader application based on Flex docs. Here is the code for that.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

   <mx:HTTPService id="blogService" url="{blogURI.text}" />

   <mx:Panel x="10" y="10" width="624" height="441" layout="absolute" id="blogPanel" title="{blogService.lastResult.rss.channel.title}">

      <mx:DataGrid x="10" y="40" id="blogDatagrid" width="584" dataProvider="{blogService.lastResult.rss.channel.item}" fontSize="14" height="174">

         <mx:columns>

            <mx:DataGridColumn headerText="Title" dataField="title"/>

            <mx:DataGridColumn headerText="Date" dataField="pubDate"/>

         </mx:columns>

      </mx:DataGrid>

      <mx:TextArea x="10" y="225" width="584" height="176" id="blogTextarea" fontSize="14" htmlText="{blogDatagrid.selectedItem.description}"/>

      <mx:TextInput x="10" y="10" width="466" id="blogURI">

         <mx:text>http://syndication.apn.co.nz/rss/nzhrsscid_000000002.xml</mx:text>

      </mx:TextInput>

      <mx:Button x="492" y="10" label="Get RSS Feed" click="blogService.send()"/>

   </mx:Panel>

</mx:Application>

New Zealand Flex usergroup now active

I joined the newly-started New Zealand Flex user group today. It feels nice to be part of a growing community of users and developers who are embracing Flex down under.

I’ve been working with Flex, on and off, for over an year and a half now. It already feels like such a long time. And what makes me giddy with excitement is that it is just the beginning.

Well, anyway, here the URL for the NZ Flex usergroup: http://groups.google.com/group/nzfxug.

Good stuff, Kai and Campbell!