A while ago I wrote about how to use a Flash SWF in a Flex application. This is another take on it, and one I hope you will find useful.

Flex comes with a great set of charts, but no maps. The example uses a map of the USA (a Flash movie) that is controlled by Flex. The map is wrapped in a Flex component so it behaves like other Flex components. For example, there is a dataProvider to color the states; there are also click and rollOver/rollOut events.

This sample demonstrates the following:

  • You can combine Flash and Flex to make an effective application.
  • Flex can easily control a Flash SWF and the SWF can report events back to the Flex application.
  • Using an MXML wrapper around the SWF makes the SWF fit better with Flex applications and provides for great reusability.

Download the zip file and extract the contents into an empty directory. The application file is USADemoApp.mxml. The Flash movie which is the map, is wrapped in USAMap.mxml and used by the application as any component.

Download Flex application

Download Flash source for the USA map

Click to view sample