
Adobe
The impetus for this article came about one day when I was tasked with porting over an MTBF (Mean Time Between Failure) application that I had written many years back from dynamic ASP pages to Flash. The original ASP code talked to a Microsoft SQL database and, of course, used server-side ASP scripts to access the data in the database. Not wanting to reinvent the wheel, I set about rewriting the interface in Flash CS3 Professional and writing ActionScript 3.0 code to talk with my team's database, which is a MySQL database rather than Microsoft SQL. By the way, that team is the Flash authoring team at Adobe.
After resolving a few slight protocol differences between Microsoft SQL and MySQL, I created the code discussed in this article. I now use this code not only for the MTBF application but also for one of our automation testing applications, as well as for some internal tools that help the Flash team track and confirm different testing metrics. My hope is that this sample application will help you jump past the boring details of hooking up to a data source and instead focus on the fun part of writing a useful rich Internet application using Flash.
This article presents a complete solution for connecting a Flash application to a back-end MySQL database using XML and a server-side ASP script. I first show you how I used Flash to create MySQL-friendly SQL calls and then wrap them up into XML that is sent to that server-side ASP script. Then I break down the ASP and show you what it does with the XML sent from Flash. Finally, I reveal how Flash parses the XML that is returned. Along the way, I introduce some valuable functions as well as an interesting technique for building up multiple MySQL calls so that the server does not have to be called multiple times.
In order to make the most of this article, you need the following software and files:
You should have at least some basic knowledge of Flash CS3 Professional and ActionScript 3.0, an understanding of how to set up and use a MySQL database, as well as an understanding of how to set up an IIS server for running the server-side ASP script. I assume that you will already have a MySQL database set up, but if you want more information on how to get and configure MySQL, go to the MySQL website. I also assume that you will have an IIS server set up, either locally or remotely, where you will run the server-side ASP script. For more information on setting up an IIS website, go to Microsoft Support.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Craig Simmons is a senior lead quality engineer on the Flash authoring team at Adobe Systems. He has been in the software industry for 17 years and worked at companies such as Macromedia and Micrografx before coming to work at Adobe. He is also a Microsoft Certified Professional in Visual Basic .NET, although he writes more ActionScript than VB these days.