What is Flex?
By Tom Haskell (Interactive Team), 25 November 2008
Some time ago I was asked by the directors here at IE to explain what Flex was, how it was different to Flash, and why I had been using it in some of our interactive projects. My initial attempt, off the top of my head, was poor - I quickly discovered that it’s not an easy concept to explain!
I was encouraged, therefore, to see that Adobe have also realised that it is confusing to those who aren’t geeked-up on all things Flash, and relaunced the Flash Platform label at their Max conference last week. The Flash Platform brings together all the different technologies that contribute to Flash-based projects, as shown in this handy diagram.
So having failed to explain it properly the first time, I did then go away and think about it and wrote an explanation of the way I understand it, which I have copied below. I seem to have unwittingly explained some of the other parts of the Flash Platform as well.
Flex
Flex is basically an ‘application framework’ for the Flash Player. Application frameworks provide developers with a set of basic to advanced objects or components out of which one can build a complete application. It is geared towards the RIA (Rich Internet Application) market and is therefore set up in such a way as to make it easier to develop these.
For a basic understanding of how it works, there is a (frankly below-par for Adobe) interactive video here.
Flex is currently in version 3, with version 4 around the corner. Read my previous blog post on some of the new features this brings.
Flash vs Flex
The whole thing gets confusing when you say “Flex compiles into Flash” - so why can’t you just do everything in Flash? “Flash” is not a very helpful term, I think it is important here to make a distinction between Flash Player and Flash Professional. Flash Player is the plugin that you install in your browser and allows you to ‘play’ or ‘run’ swf files. Flash Professional is an application that allows you to create swf files.
Technically, you probably could create everything that you could in Flex in Flash Professional, but it would be significantly harder as a lot of the built-in things in Flex aren’t available in Flash Professional, so you would have to recreate them yourself. It is also set up differently, with Flash Professional having it’s origins in animated content for the web it really isn’t very developer-friendly, with things like allowing you to attach code to almost any object, frame, group, etc. making it incredibly hard to find when it breaks (especially if someone else has written it); and the whole time-line approach which is totally alien to anyone who hasn’t worked with motion before and is a concept that no other programming language/environment has. This is a large part of the reason that Flash has not been considered for serious application development in the past.
Actionscript
The code that you compile to make an swf is written in a language called Actionscript. This is what the Flex framework is written in and is what Flash Professional uses for any programming elements. Actionscript (AS) versions 1 & 2 were pretty poor, and weren’t considered to be a serious programming language by almost all developers (myself included). AS3 (the current version) is a lot better, allowing for true Object-Oriented Programming (OOP), meaning that you can start to make proper applications in it.
It is also based on the ECMAScript 4 standard, originally designed for Javascript, which means that it is incredibly similar and much of the syntax is the same.
Flex Builder
To add even more confusion, Flex is not Flex Builder. As mentioned above, Flex is a framework, meaning that it is just a bunch of code that you can use in your application. To create the application you need to write the source code in something and then compile it. The Flex SDK (Software Development Kit) is now Open Source, meaning that it is free for anyone to use. It also comes with a command-line compiler, meaning that you could write your code in notepad if you wanted and then use the compiler to make it into an swf.
However, Adobe also sell a product called Flex Builder. This is an IDE (Integrated Development Environment) built on a very well-known and popular IDE called Eclipse. This makes it significantly easier to create Flex applications because of things like auto-code completion, automatic compilation and error checking, etc. There are 2 versions of Flex Builder - the basic one, which does the stuff mentioned here, and a professional one which also allows you to do network profiling and, more importantly, has all of the Flex Data Visualisation components (i.e. snazzy graphs).
Another important point to note is that Flex Builder doesn’t have the time-line that Flash Professional does, meaning that any animation you do has to be done through code.
Which should we use?
So this all leads us to the question of what we should be using as we go forward - Flex Builder or Flash Professional? Well I would say both. Flash Pro is still the obvious choice for animations and things like interactive banners. Actually anything that has a lot of graphical elements in it might be better produced in Flash Pro.
However, as we delve further into the RIA marketplace, Flex becomes the obvious choice. As I said before, you couldn’t realistically create an actual application in Flash Professional. There will be the additional complication there of when to use Flex and when to use html & javascript, or some combination of both.
There are of course some projects that sit in the middle, which could probably be created in either, and it will probably depend on what mood I’m in that day!
that was useful