Connecting Macromedia Flash and PHPMany web developers rely heavily on a popular combination of open source software to develop and deploy their websites and applications. This combination is often known as LAMP—an acronym for Linux, Apache, MySQL, and PHP. In this article, you will use a LAMP environment to create a PHP-based Rich Internet Application. A Macromedia Flash front end brings in data through the standard Macromedia Flash Remoting Components. You may ask, “How do I get Macromedia Flash Remoting Components to work with PHP?” Here’s how: You will use another open source project that is gaining ground and popularity, AMFPHP. AMFPHP is an application created in PHP that can connect Macromedia Flash to data, just as Macromedia Flash Remoting does with ColdFusion, .NET, and Java environments. This tutorial guides you through building a sample web service that is driven by PHP, AMFPHP, and a Macromedia Flash MX front end. As you build the web service, you will learn to install AMFPHP, create the web service, and build the Macromedia Flash MX application that ties them all together. Introducing the AMFPHP ProjectWhen building Rich Internet Applications with Macromedia Flash MX, developers often need to interact with data and information contained on their web servers. The most compelling and easy-to-use method came along with the introduction of Macromedia Flash Remoting MX. Macromedia Flash Remoting MX connects Macromedia Flash and your web application server, integrating rich Macromedia Flash content with applications built using Macromedia ColdFusion MX, Microsoft .NET, Java, and SOAP-based web services. Macromedia Flash Remoting is a great technology. However, if your development efforts revolved around a LAMP-style environment, there wasn’t a way to integrate Flash Remoting with your project without deploying additional server software and or hardware—until now. An open source project known as AMFPHP has built a solution for developers who need to integrate Macromedia Flash with PHP. According to the developers of AMFPHP, “Flash Remoting for PHP enables objects in PHP to become objects in ActionScript … AMFPHP takes care of all the data-type conversions, serialization, and other client-server details. This provides a great way of connecting rich media clients with data and logic living on the server.” The AMFPHP project has replicated almost all of the basic features and functionality of Macromedia Flash Remoting MX server. If you are wondering about the name of the project, the AMF in AMFPHP stands for Action Message Format. AMF is a binary format that can be delivered over regular HTTP and is the core of Macromedia Flash Remoting. AMF is essentially a lightweight binary version of SOAP. The AMFPHP project is currently in a development state; it has not yet reached a full 1.0 release. However, as of this writing, I have found the current release 0.5.1 to be quite robust and capable. The project also appears to be a hotbed of development activity. If you are curious, check out the CVS (content versioning system) archives for the project source files at the project’s SourceForge page. (Developers have recently added the setCredentials feature of Macromedia Flash Remoting to the latest development build found in the CVS repository of AMFPHP, although it hasn’t made it into a release yet.) If you would like to experiment with the very latest version, you need to check it out of CVS manually. Throughout this article, I am referring to the currently available release: 0.5.1. Note: If you upgrade to the full 1.0 release, the new The latest release of AMFPHP has some very good documentation and excellent examples. Also, more and more articles and examples have been showing up around the Internet recently as folks discover this alternative method of working with external data in Macromedia Flash. In this article, you will learn how to get AMFPHP working through an example that is custom-tailored for the LAMP environment. The finished sample application will help you monitor the status of your LAMP system. An added bonus: You can add this application directly to the Macromedia Flash MX authoring environment as a window that enhances your development productivity. RequirementsTo successfully complete this tutorial, you should have an understanding of the terminology and concepts behind Macromedia Flash Remoting, its implementation and usage in Macromedia Flash MX, and a working knowledge of PHP. Familiarity with object-oriented programming will also come in handy.
|