The best way to understand Flex is to think about how you build web applications right now. If you are a ColdFusion developer, or a developer who uses ASP, JSP, PHP, and the like, you probably build applications comprised of lots of linked pages. These pages contain client-code (at a minimum, HTML and JavaScript) as well as server-side code (CFML, SQL, and so forth). You probably try to separate content, or back-end data, from presentation, the front-end UI, but you still use both to create your application.
So, in the case of a ColdFusion page, a browser requests a CFML file, ColdFusion parses and processes the CFML in that file, and then returns client code to the browser. The browser renders the client code on the client, but it is ColdFusion on the server which embeds that client-code in the page. Or put differently, ColdFusion is a server that dynamically generates client-side code.
So why all this analysis? Simply put, Flex works in much the same way. Whereas ColdFusion (despite being somewhat client independent and agnostic) generates client-side HTML, Flex generates client-side Macromedia Flash SWF files. That was simply put, any maybe a bit too simplistic, but the analogy is sound; ColdFusion uses plain text files containing CFML tags to render browser content, and Flex uses text files containing MXML tags to render Macromedia Flash content. Compare the flows of both processes in figures 1 and 2.
Figure 1. A typical ColdFusion application flow
Figure 2. A typical Flex application flow
Flex is actually similar to ColdFusion in one other way. Flex, like ColdFusion, is a Java application. Flex is deployed on top of standard J2EE servers, such as Macromedia JRun, IBM Web Sphere, and so forth, in much the same way that you deploy ColdFusion, but more on that soon.
But that is where the similarities end. Unlike ColdFusion, Flex and its language, MXML, does not provide tags for database integration, sending and receiving e-mail, connecting to LDAP servers, or creating web services. Whereas ColdFusion is more of an all-purpose application development platform, Flex has a far more focused objective and a very specific goal. Flex is designed to facilitate the creation of rich and engaging presentation layers, letting developers create well-designed and optimally architected n-tier applications that adhere to standards and best practices. With Flex, coders can take advantage of the ubiquitous Flash platform from a very code-centric starting point, but what Flex generates is still Flash content. In other words, Flex is all about presentation and user interaction, and that is it.
All of the previous discussion means that Flex does not compete with ColdFusion; rather, Flex needs ColdFusion, or Java, or .NET, or something, anything, providing back-end integration. A Flex application needs a back end, and that back end can indeed be ColdFusion (as in Figure 2).
How do ColdFusion and Flex interact? The answer is that it depends; there are two distinct ways to go about using them together.