Flash
A New Role for Flash Now that Flex is Here?
Flex is here, but you still need your Flash developers.
Nov. 6, 2005 08:30 AM

Perhaps you've heard of Flex, maybe you've even dabbled with Flash, or you have one or more Flash developers on your team. Nevertheless, you aren't sure how Flash and Flex fit together.
As an enterprise application developer, I work on both the server side using Java and the client side using Flash. Knowing the benefits Flash has for the client, I looked into Macromedia's enterprise development offering, Flex. As a Flash developer myself, I saw my Flash skills being used differently on Flex-based projects. I have now begun using Flex because it fits in well with my own skills, but more important, it fits with the skills and needs of my team and our enterprise development environment. However, since I started introducing Flex to colleagues, the same questions kept popping up: "Do I need to learn Flash to use Flex?", "How does Flash work with Flex?", and "What does Flex offer that Flash doesn't?"
This article shows you, based on my own experience, how Flash and Flex work together and how the role of the Flash developer changes when involved with a Flex-oriented project.
Do I Need to Learn Flash to Use Flex?
You don't have to learn Flash to write Flex applications. Flex applications are turned into Flash movie files (the SWF file) and sent to the end-user's Flash player; this means that you can think of Flex as an alternative to using the Flash IDE (Integrated Development Environment) to make Flash movies. If you are an enterprise application developer and you've tried to learn Flash but found the concepts of the movie clip, multiple timelines, and levels a bit confusing, then Flex will be much more to your liking.
How Does Flash Work with Flex?
Flash developers play an important role in developing high-quality, enterprise-level applications. It is important to understand how Flash and Flex fit together to appreciate how valuable a Flash developer can be to your Flex team. Before Flash 5 debuted, it wasn't easy to use Flash as the sole front end to your Web application. Flash simply lacked the necessary communication link between itself and the server. When Flash 5 debuted it became possible to use Flash as a front end for Web applications. Not only could you create buttons to hyperlink to Web pages, but you could now request data from the server and modify the user interface without generating a new page. But to do this, you had to learn the Flash development environment and think in movie-making terms. This was great for the creative artist; Flash became the way to show off yourself and your company on the Web.
Tip: Flash had earned a reputation for snazzy "intro" movies, electronic greeting cards, and other, cartoonish uses. Even though it is possible to build applications in Flash 5, you have to build all of your own user interface controls. This effort, along with Flash's flamboyant reputation, didn't help convince IT organizations to use Flash instead of HTML.
Nonetheless, you probably discovered that the Flash environment is not for everyone. Just as not everyone's brain is wired to write software, not every programmer's brain is wired to think in terms of animation - a lot of us are old-fashioned, procedural-driver programmers.
Flex, on the other hand, has been clearly targeted at the enterprise Web application developer. Flex offers the advantages of Flash, but in a package that fits with enterprise development. Here's how:
- Flex applications are created in a manner similar to JSP-based applications and require an application server to run.
- The MXML files can easily be placed into source code control (with changes to them tracked - you can't do that with the binary Flash FLA files).
- MXML files can be edited by any text editor.
- ActionScript, the language of both Flash and Flex, is based on JavaScript, which many Web developers already know.
- Flex applications (that is, the MXML and related files) are deployed to production application servers as any JSP, HTML, or image file is deployed.
- Flash offers market penetration with 98% of the world's PCs running the Flash player. Furthermore, Flash applications have a much smaller download than Java applets or Java/Swing applications.
- Flash is priced for individuals and small firms; Flex is priced for corporations.
What Does Flex Offer That Flash Does Not?Since Flex applications are ultimately translated into SWF files executed by the Flash player, you may ask "Can I build the same application with Flash MX 2004 as I can with Flex?" Both Flash MX 2004 and Flex share a common look and feel. Both Flex and Flash use the halo-themed components. The on-screen objects, such as buttons and lists, have a glow, or halo, about them when you move the mouse over them. Since Flex applications are translated into Flash movies, you can logically assume that what Flex delivers, you can do in Flash MX 2004.
The short answer to the question above is, "Yes, you can." The long answer is "Yes, but why would you want to?" Flex contains more user interface components than Flash MX 2004, and Flex contains things enterprise developers are expected to provide in their applications. For instance:
- Flex contains the objects to validate phone numbers, email addresses, numbers, and strings. Feedback is automatically given to the user without the developer having to write any additional code.
- Layout managers provide the means to resize and reposition elements and happen transparently to the developer.
In the enterprise development arena, managers look at their return on investment, or ROI. If you had the choice to build an application in Flash MX 2004, but it took 3 months, versus an application built with Flex that took 1 month, which would you choose? Further, by using Flex, most members of the team could participate in the project, not just the Flash developers.
So Why Do I Need Any Flash Developers?
I have written several applications with Flash that fall into this "enterprise" category. I made extensive use of the UI controls provided by the MX 2004 Professional edition. Yet it was still a handcrafted affair. I have since reworked these applications in Flex with much success.
Tip: Applications written for Flex not only take less time to build and test, they are easier to maintain.
But there is a catch. The original Flash applications contained user interface elements that I could not create with Flex alone. For example, one of the applications has a chart that the user can manipulate. The user can drag the mouse over the chart to zoom in. Flex does not come with a component to do this.
To solve the problem, I put on my Flash hat and created a component (see Figure 1) that sits beneath the chart. When the user moves the mouse over the chart, a line follows the mouse until he/she presses the mouse button. A yellow ribbon extends from the line and follows the mouse, giving the user a clear indication of which part of the chart he/she wants to zoom.
It was very easy to add my component to the Flex project. But without any Flash skills, this embellishment would not have been possible. In this case it may have killed the project altogether since the feature is so valuable.
Tip: So what does a Flex team need with a Flash developer? The Flash developer is there, in a new role, to create more Flex components! Flex comes with over 50 components, but there is always something more you need.
Figure 2 shows a clock component added to a time-tracking application I created in Flex. The clock shows the current time and it sits under labels that are defined in Flex. The Flash component fits easily within the Flex layout of the page and is treated like any other Flex MXML tag.
Rather than charging your Flash developers with creating whole applications for your Web site, use them to augment Flex applications.
Conclusion
You do not need to learn Flash to use Flex. The design and purpose of Flex is to leverage the delivery and runtime capabilities of Flash while fitting into the enterprise development environment.
However, you cannot wholeheartedly toss away your Flash development for Flex. Flash plays too important a role. For instance, the beauty that some artists (and developers) achieve with Flash cannot be duplicated in Flex. Flex does not come with every user interface control you will ever need; Flash provides the tools necessary to create any type of control you can imagine.
Flash developers contribute to a Flex team in the following ways:
- Develop new Flex user interface components.
- Extend, or change, existing Flex components.
- Assist page designers with the ActionScript they need to make the application work. For example, data returned from a remote server call may need to be transformed so it is easier to deal with in the Flex application.
- Build new skins to change the overall look of the components. Skinning, as it is called, is the act of replacing the look of an interface with a new one. For instance, your company may have decided that all of the buttons in an application should be oval with a copper sheen. You can achieve some of this change using style sheets. But the skin determines the shape of the button. A skilled Flash developer can make new skins that fit within the theme.
Advertising, marketing, gaming, and Web site design firms have no need to fear Flex. It is simply not the best solution to deliver the types of highly artistic and interactive solutions those firms produce. If your business makes form-based applications, e-commerce applications, or relies heavily on JSP, then Flex is right for you. If you have been pushing Flash to new limits, you'll find those skills very useful in Flex.
For the enterprise Web application developer, Flash takes a new supporting role on the stage where Flex is the star player.
About Peter EntPeter Ent is a Web application developer specializing in Rich Internet Applications. He has more than 20 years of experience ranging from keypunches to wireless PCs.