RIAs, Adobe Flex, and related topics

About
Resume
Contact

February 18, 2008

Refurbishing antiques with LocalConnection

Filed under: Flash, Flex — jimrobson @ 11:37 am

There’s a room in my house that has a pair of old-fashioned wingback chairs set in front of a large Scandinavian bookshelf unit. I like the way this arrangement looks; the graceful curves of the Queen Anne style chairs contrast nicely with the hard, sleek lines of the bookcase. And it would seem that I’m not alone; lots of people like to juxtapose classic older styles with contemporary ones. In order to do this successfully, of course, the older item often needs a bit of work: hardware replacement, scratches and dings filled in, or perhaps a complete refinishing job. But the result is often more than worth the effort. And this exercise is not only aesthetically pleasing, it helps to minimize waste by putting an old item to use that might otherwise have been destined for the rubbish pile.

We now have a somewhat analogous situation in the Flash development world - especially those of us who have been working with the technology for several years. We all have old Flash assets lying around that are potentially useful, but they don’t have all of the functionality we need, and they can’t be imported into ActionScript 3 projects. So what do we do with them?

One answer is to use the LocalConnection class to enable these antiques to communicate with our current projects. With LocalConnection, any two (or more) SWFs running in the end user’s Flash player can send messages to each other regardless of what version the SWFs are compiled to or which version of ActionScript they use.

Suppose, for example, that you are asked to build an application that has a clickable U.S. map. When the user selects a state, a pie chart displays the relative amounts spent on various types of candy bar in that state. Flex Charting can take care of the pie chart pretty easily, but what about the map? Suppose you have an old interactive map built in Flash 5 laying around, and you want to use that rather than building a new one from scratch. Well, that is precisely what was done here:

ChartMap application screen shot

This application uses a Flash 5 map of the U.S. loaded into a Flex 2.0 application. Just a few lines of LocalConnection code added to the version 5 FLA were sufficient to enable this perfectly useful old asset to communicate with its ActionScript 3 host. Apart from the developer, the only people who could tell the difference between this application and one built completely from scratch are the people who pay the bill - they could see it in the money they save.

As an aside, you’ll also notice that the Flex project included in this application illustrates a few interesting things in addition to the LocalConnection code:

  • The use of a custom renderer component to build a custom legend
  • Using a custom color palette with a Flex chart
  • Using the interpolate effect to animate a pie chart
  • An AS3 helper class to read, manipulate, and generate XML data

You can run the complete application here. When the application opens, right-click on it to view and download the source.

Note: The XML data file used for this application is a work of fiction. Any resemblance to actual sales figures or percentages, living or dead, is entirely coincidental.

Enjoy!

February 1, 2008

Site update (at long last)

Filed under: Blog, W3C Standards, Web design — jimrobson @ 9:21 pm

I just treated my website to a long-overdue face lift - it’s been at least three years since the last time I gave it any serious attention. This is the first time that it meets W3C standards for markup and style, because it never seemed to be worth the effort until now. At this point, however, the browsers and the design tools have matured such that I was able to create a look and feel that is reasonably consistent across browsers and at the same time abide by the standards without banging my head against the nearest wall. Of course, I’ve only tested it in Windows with IE6, IE7, Opera 9, and Firefox 2, so it’s possible that one of my friends with a Mac will have some bad news for me - but I hope not.

Now I need to tweak this blog’s CSS so that it coordinates with the look of the static site.

*UPDATE:

I’ve modified the blog’s css and added some links to the static site. It would look much better if I didn’t need to make adjustments in the layout to accommodate IE6. If you’re using IE, please switch to a really good browser now, before you forget about it again. If you don’t like Firefox, then try Opera. If you insist on using IE, and you’re still using an older version, please at least upgrade to the current version!


Powered by WordPress