Using Flash Player 8 Features in Your Flex 1.5 Application
Macromedia Flash Player 8 is here and packed with useful and innovative features. Performance and memory consumption are also significantly improved in the new player, and you will notice the improvement without changing a line of code or recompiling.
As a Flex developer, you will probably spot immediate opportunities to use some of the new features in Flash 8:
* File upload and download-a frequent request from developers
* A new ActionScript API to allow developers to directly manipulate the Input Method Editor (IME). Using this feature, you have direct control over the conversion mode used at any particular point in your application, and conversion modes can dynamically change as a user navigates around the application. So, for example, you can switch between hiragana and katakana, while the user has the Japanese IME enabled.
* For more information about the key Flash Player 8 features you might want to incorporate into your Flex 1.5 application, see Flash Player 8 and Flex 1.5.
So, Flash Player 8 provides a lot of great features. How do you take advantage of these features in Flex 1.5? This article explains how you can take advantage of the new features in Flash Player 8 by building content for it using the Flash 8 authoring tool and then loading the resulting SWF file into a Loader component in your Flex application. The process is simple and straightforward. You continue to build all your application interface and logic in Flex and simply leverage a small library of Flash Player 8 functions. Better yet, for the file upload and download feature, we provide a code example in this article that you can drop into your Flex 1.5 applications without needing to use the Flash authoring tool.
Flash Player 8 delivers a host of new features and capabilities. While it’s tempting to access the APIs directly in ActionScript and compile and run your Flex 1.5 application leveraging those features, this won’t work for several reasons. Primarily, the Flex 1.5 compiler won’t recognize the new ActionScript statements. It is hard-coded to produce Flash Player 7 SWF files. An upcoming release of Flex will give full support for Flash Player 8.
Don’t despair, however, you can still leverage many of the features in Flash Player 8 using a different method. First, you can build small blocks of Flash Player 8 SWF files using the Flash 8 authoring tool, producing libraries of Flash Player 8 classes that you can use in your Flex 1.5 applications. Then, you can load Flash Player 8 SWF files into your Flex 1.5 applications using a Loader component and gain access to them in your Flex 1.5 application through ActionScript. The approach is simple and gives you access to many of the Flash Player 8 features most requested by Flex developers.
There are a couple of ways of achieving this. You can create Flash Player 8 SWF files that have no user interface and just provide a set of classes and methods to use in your Flex 1.5 application. Or, you can build whole interfaces in Flash Player 8 content that display and run in your Flex application. Regardless of the approach you choose, you can communicate events, properties, and call methods in the SWF or the Flex application easily.
Through all of this, remember the Flash Player 8 security model. Be careful about loading SWF files and accessing information from other domains. For more information on the Flash Player 8 security model, see the Flash Player Developer Center.
File Upload and Download Example
For this example, you learn how to use a small Flash Player 8 SWF file loaded into your Flex application. This Flash Player 8 content was created using the Flash 8 authoring tool. It has no user interface, so effectively it only provides you with a library of classes to use for file transfer; you continue to use Flex to build the entire interface and logic of your application.
There are actually two examples here. The first example is the simplest way to include file upload functionality in your Flex application and illustrates how you can include this feature in your applications. The second example elaborates on the simple file upload functionality and integrates the feature into a typical enterprise Flex architecture. It also gives you event logging, progress monitoring, and other useful features. Use the second example if you have a sophisticated, architected application.
Louise Garver, CMP, CPRW, JCTC, CEIP, MCDP, has assisted senior executives and management clients worldwide in all aspects of job search, interviewing and negotiations, development of resume and marketing letters, career transition and career management since 1985. President of Career Directions, LLC, she is an award-winning, published and certified career coach, professional resume writer, outplacement consultant and former corporate recruiter. For help in winning the career your deserve, visit http://www.resumeimpact.com.