Wednesday, June 6, 2007

AMFPHP vs WebServices vs FlashVars

1Coming from a PHP background I am used to connecting my applications to databases or other sources to make for a dynamic user experience. Flash has never supported native connections to databases for supposed security reasons, many thought that with the development of Flex adobe would drop this policy and allow this more data-driven language to talk with databases, but these people were all wrong. This is a major disadvantage for Flash and in turn Flex because it adds another step in the process of developing any truly dynamic website.

The workarounds that Flash ahas offered involve its HTTPService object and also some Web Services connectivity options. Using web services is definately more standards compliant, cross-browser and language compatible but it is much more difficult than a simple sql call to an open database connection. A quirky but simple workaround also involves the flashvars way of importing data, a very flash-specific way of doing things it does work as a solution to quickly get remote data into a flash application, actually this is the method that I used to get the listing and picture information onto my example at http://lesliehancock.com/flash35 The data for this project came from http://www.lesliehancock.com/data/listingdata.php?listing_id=123 Which you can see is formatted much like a normal get url string.

When I first was trying to add server-side data into my flex application I did plenty of googleing and found something called AMFPHP, this is a process for accessing remote php objects through flash. The trouble is that AMFPHP hasn't been worked on for 8 or 9 months and that is a long time for an open-source project that is still in beta. Also the AMFPHP model requires you to have identical objects in Actionscript and PHP and to use AMFPHP to handle the interaction, this is obviously a little redundant and after experimenting with this project of lofty ambition I decided to stick with XML and Web Services

The best way to handle the lack of built-in support for database access is to become very handy with web services, or at least creating xml files to some sort of standard. This way the data can be used with a wide variety of applications and can be produced from a wide variety of server-side languages.

No comments: