Thursday, 13 March 2008

Flex... ah ha?



Many people have heard of “Flash” within the context of the internet. Not so many people have heard of Flex. So what is it? To the end user it appears to be the same thing - Flex compiles to the same format (you use the flash player to view Flex application) and it uses the latest, greatest version of Actionscript as Flash does, but there are fundamental differences.

The biggest of these, is that we can no longer hum the Flash Gordon tune when someone mentions it. Less importantly, the focus is different. Flash has evolved to be about wooshy things. It is at its best with pretty, moving things and adding interactivity to said moving things. Developing in flash generally requires creating movieclips and then moving them about. Flex changes this; and seems to have been written with business applications and speed of development more in mind. Certainly much of what I have read indicates that intranet applications benefit greatly from Flex development.

We have recently started using Flex for its first in-house project, and deadlines have meant that the time I had to put it through its paces before-hand was severely limited. The honeymoon period of the first few minutes, all was sunshine and rainbows. In much the same way as building a .NET application, you can drag what you need (e.g. form items which are neat little self contained components) into your design window. These components mean that things like date selectors can be very quickly added, rather than writing a proprietary one (or using one from an in-house, but still custom, library). If you prefer to get your hands dirty, you can also view the source of this page and construct the application by creating what is effectively an xml document. This will no doubt be the preferred method for programmers, but it’s very useful to have the choice especially if you wish to then pass it over to developers to pretty it up or add style sheets.

Among the first things I missed were the ability to zoom into the design panel, or being able to draw shapes directly onto the stage. Fortunately, the project in question had little need for dinosaurs running about all over the place so this wasn’t an issue. Also, this was more than made up for by the code auto-complete offered by the editor. I have since learned that some people use the Flex Builder purely to write and edit Actionscript for Flash application solely because of the convenience of this auto-complete.

Nonetheless, to my lasting joy, I was still given many opportunities to reacquaint myself with Google. Little problems (e.g. editing data in datagrids – a way of displaying tabular information – using drop down lists) kept tripping me up. Sometimes the answers were deceptively simple but other times they were somewhat depressing (on more than one occasion, I have found that the problem was with the Flex compiler itself and not in my code – especially frustrating when I then learn it was only fixed in a later version). Another slight bother has been that it seems to be slightly slower to actually render a particularly busy page than flash was, but there are solutions to this and it may become less of an issue with more experience.

During the initial learning curve, the potential gain in development time has been offset by the need to learn the various foibles of Flex development. However, these benefits have been missed on the occasions where I have flitted back to Flash to modify something that could have been better written in Flex.

Ultimately, Flex is just a tool that like any tool only offers its true benefits when used correctly. However, when used correctly Flex could be a valuable tool in the Bluhalo digital belt.

No comments: