<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>AaronHardy.com &#187; serialization</title>
	<atom:link href="http://aaronhardy.com/tag/serialization/feed/" rel="self" type="application/rss+xml" />
	<link>http://aaronhardy.com</link>
	<description>For all your Aaron Hardy needs.</description>
	<lastBuildDate>Thu, 12 Jan 2012 17:51:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple AMFPHP Example</title>
		<link>http://aaronhardy.com/flex/simple-amfphp-example/</link>
		<comments>http://aaronhardy.com/flex/simple-amfphp-example/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 04:24:14 +0000</pubDate>
		<dc:creator>Aaron Hardy</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[amf]]></category>
		<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://intimateconversations.aaronhardy.com/php/simple-amfphp-example/</guid>
		<description><![CDATA[With the advent of Flex and RIA (Rich Internet Application) development came AMF (Action Message Format). Flex, in general, focuses only on front-end functionality, meaning it does not directly hit a database to store or retrieve persistent data. Instead, database calls are written in a more traditional back-end language like Java, PHP, Python, or .NET [...]]]></description>
			<content:encoded><![CDATA[<p>With the advent of Flex and RIA (Rich Internet Application) development came AMF (Action Message Format).  Flex, in general, focuses only on front-end functionality, meaning it does not directly hit a database to store or retrieve persistent data.  Instead, database calls are written in a more traditional back-end language like Java, PHP, Python, or .NET and such services are then exposed to be &#8220;consumed&#8221; (used) by the Flex front-end.</p>
<p>AMF is a protocol that allows ActionScript (the language of Flash/Flex) to call services exposed by the back-end.  Additionally, if you choose, AMF allows you to translate a programmer-defined object between ActionScript and your back-end language of choice.  In other words, if you have a customer class in ActionScript and you want to pass an instantiated customer object to the back-end, you simply call the exposed back-end service and pass the customer object as a parameter.  The AMF layer transparently translates the ActionScript customer object into, let&#8217;s say, a customer object in Java.  This functionality isn&#8217;t required.  Instead of using a class you have defined, you could instead just send an integer to the backend as a parameter and, after processing, send a string back to the front-end.<span id="more-33"></span></p>
<p>Before checking out my example, I recommend checking out the <a href="http://en.wikipedia.org/wiki/Action_Message_Format" target="_blank">Wikipedia Action Message Format article</a> to get a basic description of AMF and links to implementations for various back-end languages.  I also recommend reading <a href="http://nothinghappens.net/?p=198" target="_blank">AMFPHP class mapping explained</a> by Chuck Hoffman to get a good understanding of the object translation I just described.  Finally, head on over to <a href="http://amfphp.org/" target="_blank">amfphp.org</a> (the creators of AMFPHP) to get a glimpse of available documentation, files, etc.  I might add that if any of the folks over at amfphp.org don&#8217;t like me distributing AMFPHP code, let me know and I&#8217;ll modify the files I&#8217;ve posted for download.  The zip file below currently contains everything you&#8217;ll need to get a simple example up and running.  Now to the example&#8230;</p>
<p><a href='/wp-content/uploads/2008/02/simpleamfphp.zip' title='Simple AMFPHP Example'>Simple AMFPHP Example Zip File</a></p>
<p>For the example, I made a Kite Finder.  Basically, you enter in a kite pilot&#8217;s name and Flex populates a person object with the pilot name entered.  Flex then calls a PHP service function using AMFPHP which translates the ActionScript person object to a PHP person object on the backend.  In a real environment, you would then use information from the person object to hit a database to find the pilot&#8217;s kite.  In our example, we just build a kite object using dummy data.  Our PHP function then returns the kite object, which AMFPHP ships back to the Flex front-end, translating it to an ActionScript kite object.  In reality, the person and kite classes might be a little overboard for such a simple example.  I could&#8217;ve just passed two string parameters (the pilot&#8217;s first and last name) to the PHP function and an associative array (kite info) back to the front-end, but I wanted to demonstrate AMFPHP&#8217;s object translation.</p>
<p>Setting up the example is fairly easy:</p>
<ol>
<li>Upload the amfphp directory to the root directory of your website.</li>
<li>Open the SimpleAMFPHP project in FlexBuilder and modify the &#8220;gateway&#8221; variable in FindKiteCommand to point to your new gateway address.</li>
</ol>
<p>That&#8217;s all!  You should be able to deploy the project from within FlexBuilder and see it in action.  This should work even if you&#8217;re using <a href="http://www.hostingobserver.com" target="_blank">inexpensive web hosting</a>.  If you have questions on where code is, what&#8217;s happening, how to do something, or anything else, please&#8230;join the intimate conversation!</p>
]]></content:encoded>
			<wfw:commentRss>http://aaronhardy.com/flex/simple-amfphp-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

