Flex was designed in order to give Flash Developers an edge when developing Rich Internet Applications (RIAs). Although RIAs can be built from within Flash, there are various limitations, especially when it comes to a developer’s time.
One of the major reasons why Flex is becoming more and more popular is because it utilizes ActionScript 3.0. One important thing to note is that the Flex environment does not use a Timeline. This does not mean that it is limited. Rather, Flex has been developed more for programmers and less for designers.
Let’s take a look at the reasons to love to develop RIAs (Rich Internet Applications) in Flex.
- Flash is everywhere — The Adobe Flash 9 Player has about 98% market penetration across browsers. This means that when you launch an application on the Web, you are virtually guaranteed that anyone will be able to use it. Compared to the distribution statistics of other RIA runtimes, there is simply no contest.
Flash is cross-OS, or “platform-agnostic”: it runs in Windows, Mac and Linux. It is also installed in every type of browser, making it the only RIA technology that can truly claim to be a “write once, run everywhere” platform.
- Flex = Flash on steroids — Flex is Flash and Flash is ActionScript 3.0 (or more specifically, Flex runs on the Flash Player, and the Flash Player’s language is ActionScript 3.0.)
In ActionScript 3.0 you have all the aspects of a mature, robust programming language: strong runtime typing, class inheritance, interfaces, error handling, a built-in event model, sealed classes, method closures, custom namespace accessors, regular expressions, E4X. The Flash Player incorporates the Tamarin ActionScript 3.0 Virtual Machine with the power of a Just in Time (JIT) compiler, which interprets SWF application bytecode into machine-level instructions so that your code runs as fast as the processor can handle. Warp speed, Scotty!
And since Flex is built on top of Flash, you have the full power of the Flash APIs to draw in real time with lines, gradients and fills and manipulate and animate vectors, bitmap data, and visual assets, complete with matrix transformations, programmatic Photoshop-like filters, and blends. Flash allows communication using a dizzying array of data formats, but if you don’t find the format that suits your needs, create your own using a binary socket and custom interpreter! You also get high-definition, full-screen, hardware-accelerated video capabilities, supported by enterprise-capable video encoding and streaming server products.
Flex 3 adds another layer of power onto the Flash runtime: a visual markup language called MXML, and a full-featured compiler that includes compiler metadata and data binding. The Flex framework adds class libraries for natively managing HTTP requests, RPC services, and Web Services, a dizzying array of visual UI components, a deep linking framework for browser integration, an API for AIR applications that can interact natively with the desktop, logging and unit testing frameworks, and much much more, all of which will be covered in this book. Not to mention an IDE based on Eclipse, and a whole suite of server tools for your application to communicate with the backend using native ActionScript class objects.
- Flex is open source — The Flex Software Development Kit (SDK), which comprises the compiler, the component framework, and several other tools, is a free, open-source development platform. Although Flex Builder is neither free nor open source, it is built upon Eclipse, and can be installed standalone (with Eclipse built in) or as an Eclipse plug-in alongside other Eclipse development environments. In fact, Adobe Flex Builder has been voted Best Open Source Developer Tool for RIAs by InfoWorld’s Best of Open Source Software Awards.
The Flash Player also includes XML and binary sockets capability, including traditional GET and POST HTTP requests.
The Flash Player natively supports image file formats GIF, JPG, PNG, media file formats MP3, FLV, F4P, F4A, and F4V, including the AAC, MP4, M4V, M4A, 3GP, and MOV multimedia container formats, encoded in Sorenson Spark, On2VP6, H.264, MPEG-4, MP3, or AAC.
The Flash Platform also enables some unique RIA communications protocols. Connected to the Flash Media Server, the Flash Player is also able to stream video and audio using the RTMP protocol, and its rights-encrypted cousin RTMPE, as well as the new RTMFP format in Flash 10. Using the Adobe AMF protocol, the Flash Player is able to communicate complex ActionScript objects directly with data services applications on the server. Adobe LiveCycle Data Services and its open-source cousin BlazeDS enable bidirectional ActionScript-to-Java object transfer, and the ColdFusion server allows for ActionScript-to-CFC object transfer. Third-party data service implementations such as WebOrb, AMFphp, and Zend enable native ActionScript object communication with the.NET and PHP server languages. Other third-party data services solutions exist for languages such as Ruby and Python.
The Flex framework contains APIs that allow very easy deployment for HTTP requests, Web Services, and RPC services data transfers. So needless to say, a Flex application can communicate a wide variety of web technologies, allowing for a plethora of server integration options with an impressive array of interoperability with many data formats, languages, and protocols.
- The community — Conceived with the same spirit as the Flash community, the Flex community is passionate, generous, and vibrant, always coming up with new ways to alert each other of the latest quirks, share their discoveries, their tips, their components, and their experiments, helping Adobe make a better product. And Adobe does an incredible job of feeding that fire: it actually listens to the community, and rewards them with changes to product development that directly reflect what designers and developers has been asking for, going so far as to organize events and surveys that elicit feedback for the sole purpose of making Flash and Flex better and better. One has only to look at all the new features in Flash Player 10 and those planned for Flex 4 to know that Adobe has listened to and cares about its community. Many Flash and Flex designers and developers, including the writers of this book, really enjoy what they do for a living, and thrive on that energy. And this level of passion and commitment to each other and to the evolution of the platform shows through in every Flash and Flex conference, every technical blog, every community forum and list this author has ever visited.
- Creative Suite integration — When Adobe purchased Macromedia in 2005, it brought to the Flash and Flex development scene the possibility of the full force of its Creative Suite of applications. As of Creative Suite 3, we can now experience the fruits of that promise, as we now have seamless integration between Flash and Illustrator, Fireworks and After Effects. This opens up a vast sea of creative possibilities for Flex development, enabling even “richer media” applications than ever before. See Chapters 26 and 29, which cover Flash and Flex workflow integration in greater detail.
- Flex enables modular, rapid application development (RAD) — Flex natively encourages a Model-View-Controller (MVC) separation of application parts through the use of MXML, which is an XML-based visual layout markup language that facilitates rapid prototyping and development (see Listing 1-1 for details). In the simplest Flex MVC pattern, the View or interface layout is typically coded in CSS and MXML, and the Controller or application logic is typically coded in ActionScript, though one is not constrained to these norms. This will be covered in greater detail in Chapter 60, “MVC Frameworks.” Flex Builder also has a Design View, which allows for the visualization of MXML layouts, and a Properties View, which allows for the setting of inspectable component properties directly in the IDE (see Chapter 5, “Introduction to Flex Builder 3,” for details).
Flex also enables a variety of modular compilation and deployment methods. You can pre-compile application modules or class libraries to increase compilation efficiency, code distribution, or asset management. By compiling all your fonts into one module, and all your skins into another module, for example, you cut down overall application compilation time and increase asset management efficiency. You can compile SWFs to be compiled in the main application as embedded assets, which can be easier to use than Flex modules, or you can opt to load SWF application subcomponents at runtime, decreasing the initial application filesize.
The application footprint can also be mitigated by the use of persistent framework caching, where you can compile your application sans the Flex framework, allowing the Flash Player runtime to preload and cache the framework as a separate class library on the client. This means that after the Flex framework has been downloaded once, it is cached on the client, and your application will load much quicker for the user. See Chapter 66, “Modular Application Development,” for details.
- Seeing is believing — But don’t take our word for it. Check out some Flex and AIR applications yourself. Have a look at some of the showcased applications, and you’ll see exactly what we mean: