<?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/"
	>

<channel>
	<title>Seaquest &#187; AMF 3 Photo Data Objects</title>
	<atom:link href="http://www.seaquest.com/tag/amf-3-photo-data-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seaquest.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 06 Jun 2010 18:39:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>My Adobe Flex / PHP Client / Server Articles on O&#8217;Reilly InsideRIA</title>
		<link>http://www.seaquest.com/2010/06/06/my-adobe-flex-php-client-server-articles-on-oreilly-insideria/</link>
		<comments>http://www.seaquest.com/2010/06/06/my-adobe-flex-php-client-server-articles-on-oreilly-insideria/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 18:39:04 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[AMF 3]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[Maté Framework]]></category>
		<category><![CDATA[MySQL Database]]></category>
		<category><![CDATA[PHP Application Server]]></category>
		<category><![CDATA[Photo Gallery]]></category>
		<category><![CDATA[RIA Client / Server]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[WebORB for PHP]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AMF 3 Photo Data Objects]]></category>
		<category><![CDATA[AS 3 ByteArray]]></category>
		<category><![CDATA[Photos and PHP]]></category>
		<category><![CDATA[RIA Photo Gallery]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.seaquest.com/?p=97</guid>
		<description><![CDATA[Following are my five articles on O&#8217;Reilly InsideRIA related to developing Adobe Flex clients using Adobe Flash Builder, which resource data from PHP Web application servers. AMF3 PHP Server Objects to Flex Client Object Relational Mapping Processing AMF 3 PHP Server Object Arrays on the Flex Client Using Object Relational Mapping Photo Gallery Maté Framework, [...]]]></description>
			<content:encoded><![CDATA[<p>Following are my five articles on <strong><a href="http://www.insideria.com" target="_blank">O&#8217;Reilly InsideRIA</a></strong> related to developing Adobe Flex clients using <a href="http://www.adobe.com/products/flashbuilder" target="_blank"><strong>Adobe Flash Builder</strong></a>, which resource data from PHP Web application servers.</p>
<p><a href="http://www.insideria.com/2008/04/amf3-php-server-objects-to-fle.html" target="_blank"><strong>AMF3 PHP Server Objects to Flex Client Object Relational Mapping</strong></a></p>
<p><strong><a href="http://www.insideria.com/2009/03/amf3-php-server-objects-to-fle-1.html" target="_blank">Processing AMF 3 PHP Server Object Arrays on the Flex Client Using Object Relational Mapping</a></strong></p>
<p><strong><a href="http://www.insideria.com/2010/02/photo-gallery-mate-framework-w.html" target="_blank">Photo Gallery Maté Framework, With Photo Caching</a></strong></p>
<p><strong><a href="http://www.insideria.com/2010/05/flex-4-php-data-centric-soluti.html" target="_blank">Flex 4 / PHP Data-Centric Solutions</a></strong></p>
<p><strong><a href="http://www.insideria.com/2010/06/flex-4-php-data-centric-photo.html" target="_blank">Flex 4 / PHP Data-Centric Photo Transfers</a></strong></p>
<p>Note: if you plan to use the example code in my article <strong>Photo Gallery Maté Framework, With Photo Caching</strong>, then also be sure to read my article <strong>Flex 4 / PHP Data-Centric Photo Transfers</strong>.</p>
<p>Enjoy!</p>
<p>Pete</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seaquest.com/2010/06/06/my-adobe-flex-php-client-server-articles-on-oreilly-insideria/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>O&#8217;Reilly InsideRIA: Photo Gallery Maté Framework, With Photo Caching Article</title>
		<link>http://www.seaquest.com/2010/02/01/insideria-photo-gallery-mate-framework-with-photo-caching-article/</link>
		<comments>http://www.seaquest.com/2010/02/01/insideria-photo-gallery-mate-framework-with-photo-caching-article/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 01:45:00 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[AMF 3]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[Maté Framework]]></category>
		<category><![CDATA[MySQL Database]]></category>
		<category><![CDATA[Photo Gallery]]></category>
		<category><![CDATA[RIA Client / Server]]></category>
		<category><![CDATA[WebORB for PHP]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Adobe Flex Builder]]></category>
		<category><![CDATA[AMF 3 Photo Data Objects]]></category>
		<category><![CDATA[AS 3 ByteArray]]></category>
		<category><![CDATA[Photos and PHP]]></category>
		<category><![CDATA[RIA Photo Gallery]]></category>

		<guid isPermaLink="false">http://www.seaquest.com/?p=31</guid>
		<description><![CDATA[I have been developing Adobe Flex-based RIA applications for nearly three years. My prominent need has been for capable RIA photo galleries. I observed over time that most Flex-based example photo galleries resourced photos—either locally or remotely—from photo files stashed in folders or folder hierarchy. There are better ways using Adobe Flex Builder to create RIA clients, what are driven from a photo database repository residing on a remote PHP Web application server.]]></description>
			<content:encoded><![CDATA[<p>My article titled <a href="http://www.insideria.com/2010/02/photo-gallery-mate-framework-w.html" target="_blank"><em>Photo Gallery Maté Framework, With Photo Caching</em></a> has just been published on  the <a title="InsideRIA" href="http://www.insideria.com/" target="_blank">O&#8217;REILLY  InsideRIA</a> blog.</p>
<p>I have have been developing Adobe Flex-based RIA applications for nearly three years. My prominent need has been for capable RIA photo galleries. I observed over time that most Adobe Flex-based example photo galleries resourced photos—either locally or remotely—from photo files stashed in folders or folder hierarchy. There are better ways using Adobe Flex Builder to create RIA clients, what are driven from a photo database repository residing on a remote PHP Web application server.</p>
<p>The article&#8217;s <a href="http://gallery.seaquest.com/" target="_blank">example photo gallery</a> is a worthwhile visit to better appreciate what my InsideRIA article is all about. And if you mouse right-click in your Web browser, you can view the source code for this photo gallery. Visit the <a href="http://www.insideria.com/2010/02/photo-gallery-mate-framework-w.html" target="_blank">InsideRIA article</a> for the details of how this photo gallery client / server solution works along with a detailed analysis of core software code.</p>
<p>Noteworthy to this article is my adjunct blog note titled <a href="http://www.seaquest.com/2009/12/18/adobe-amf-3-transfer-of-photo-data-from-a-php-application-server-to-a-adobe-flex-client/" target="_self">Adobe AMF 3 Transfer of Photo Data From a PHP Application Server To a Adobe Flex Client</a>. This article expands on  issues with PHP string data types when when transferring photos from the Web application server to the Flex client.</p>
<p>If you need additional basic information related to developing and deploying Flex Builder to PHP application server, client / sever remoting, then see my two earlier <strong>InsideRIA</strong> blog articles on these topics:</p>
<ul>
<li><em><a href="http://www.insideria.com/2008/04/amf3-php-server-objects-to-fle.html" target="_blank">AMF3 PHP Server Objects to Flex Client Object Relational Mapping</a></em></li>
<li><em><a href="http://www.insideria.com/2009/03/amf3-php-server-objects-to-fle-1.html" target="_blank">Processing AMF 3 PHP Server Object Arrays on the Flex Client Using Object Relational Mapping</a></em></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.seaquest.com/2010/02/01/insideria-photo-gallery-mate-framework-with-photo-caching-article/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Adobe AMF 3 Transfer of Photo Data From a PHP Application Server To a Adobe Flex Client</title>
		<link>http://www.seaquest.com/2009/12/18/adobe-amf-3-transfer-of-photo-data-from-a-php-application-server-to-a-adobe-flex-client/</link>
		<comments>http://www.seaquest.com/2009/12/18/adobe-amf-3-transfer-of-photo-data-from-a-php-application-server-to-a-adobe-flex-client/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 00:39:02 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[MySQL Database]]></category>
		<category><![CDATA[Photo Gallery]]></category>
		<category><![CDATA[RIA Client / Server]]></category>
		<category><![CDATA[WebORB for PHP]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[AMF 3]]></category>
		<category><![CDATA[AMF 3 Photo Data Objects]]></category>
		<category><![CDATA[AS 3 ByteArray]]></category>
		<category><![CDATA[Photos and PHP]]></category>
		<category><![CDATA[RIA Photo Gallery]]></category>

		<guid isPermaLink="false">http://www.seaquest.com/?p=17</guid>
		<description><![CDATA[Author&#8217;s Update, June 1, 2010 This article describes how and why you need to modify the WebORB for PHP internal PHP code so that you can transfer photos from the PHP server to the Flex client, arriving as ActionScript 3 ByteArray data type. This internal PHP code modifications, described later in this article are no [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: red;">Author&#8217;s Update, June 1, 2010</span></strong><br />
This article describes how and why you need to modify the <strong>WebORB for PHP</strong> internal PHP code so that you can transfer photos from the PHP server to the Flex client, arriving as ActionScript 3 ByteArray data type. This internal PHP code modifications, described later in this article are no longer necessary. I recently identified a new way perform this photo data transfer by replacing the <strong>WebORB for PHP </strong>application server with<a href="http://www.zend.com" target="_blank"> Zend&#8217;s</a> <strong><a href="http://framework.zend.com" target="_blank">Zend Framework</a></strong> application server. <strong>Zend Framework</strong> supports photo data transfers without requiring internal code modification of PHP code within the framework. See my <a href="http://www.insideria.com" target="_blank">InsideRIA</a> article <a href="http://www.insideria.com/2010/06/flex-4-php-data-centric-photo.html" target="_blank"><strong>Flex 4 / PHP Data-Centric Photo Transfers</strong></a> for details on how to replace <strong>WebORB for PHP</strong> with <strong>Zend Framework</strong>.</p>
<p><span style="color: red;">________________________</span></p>
<p>Transferring photos from the PHP server to the Flex client via AMF 3 RemoteObject data streams is currently one of my favorite RIA topics. That&#8217;s because it took me more than a few days to figure out why I was able to display my photos when they were on the PHP server, but I could no longer display them by the time they were received by my Flex client. I&#8217;m anxious to share what I know about this in the hope that others do not have to go through what I did to get this working properly. The subtleties of what happens during the server-to-client photo data transfer are enough to drive you up the wall.</p>
<p>Here&#8217;s the scenario, what you&#8217;ll require and the specific solution that helped me.</p>
<p>In my SQGallery application article in <a href="http://www.insideria.com/">InsideRIA</a>, we were discussing a Flex-based photo rendering RIA named SQGallery that pulls the photos from a MySQL database with Action Message Format (AMF3) Messaging through the WebORB for PHP application server. The dilemma is that the PHP data types are somewhat restricted in what&#8217;s available to meet our needs. Principally, the PHP data types are four scalar types: boolean, integer, float (floating-point number, a.k.a. &#8216;double&#8217;) and string; two compound types: array and object; and finally two special types: resource and NULL.</p>
<p>When the WebORB PHP application server loads photo data — effectively an array of bytes — from the SQPhoto MySQL database, PHP insists on typing photos as a string data type. Ah, I thought, all sounds well and good. I will simply return the photo PHP string photo byte array to the Flex client, receiving the photo data as an ActionScript 3 (AS3) String object. Then I will cast the String AS3 object to a ByteArray AS3 object so that the photo can be rendered and displayed using the Loader AS3 class.</p>
<p>The above is a great idea, but it did not work. I wondered why. After all, PHP strings are AS3 Strings &#8230; or are they? The AS3 String objects are formatted UTF-8, which means single-byte strings — the same as PHP server-side strings, right? You are wrong by 100%. In ActionScript, if the eighth bit (bit 7) of any byte is set (1), then the UTF-8 single byte is extended to a two-byte UTF-8 sequence. And guess what? Many of the photo string (array of bytes) have the eighth bit set. Talk about messing the photo content up! No wonder photos won&#8217;t display in the SQGallery Flex client.</p>
<p><span id="more-17"></span>I thought of an easy fix. Just cast the server-side PHP photo string to a ByteArray and receive the photos as AS3 ByteArray objects on the Flex client. After all, I know by looking at Adobe&#8217;s AMF 3 specification that the ByteArray data type is supported.</p>
<p>Two issues broke what I thought was a clever solution. First, while there is no PHP compile error, casting photos to PHP (ByteArray) does not work. PHP still insists that my photo array of bytes is a string. That&#8217;s because there is no ByteArray data type in the PHP language syntax.</p>
<p>The lack of a ByteArray (or, for that matter, a byte) data type in PHP is the cause of the second issue as well. While the AMF 3 specification says yes to of support ByteArray data types, WebORB for PHP does not support this data type. One cannot support what does not exist.</p>
<p>So there I was, trapped with a neat server-to-client photo search request to render and display photos with no way to transfer the photo data. Panic set in! Should I just scrap my code and move on to another endeavor-or jump from PHP to using Adobe&#8217;s ColdFusion or Adobe&#8217;s BlazeDS application servers? I knew these two server solutions both directly support AMF 3 RemoteObject data transfers.</p>
<p>But wait, there&#8217;s more! Eureka, at last I came up with a solution, albeit a bit of a kludge, that would surely work. I knew that JPEG and Portable Network Graphic (PNG) photos each have a unique set of identifying header bytes at the start of the photo byte data. Furthermore, the format specifications of these photo header bytes are easily obtainable via a couple of Google searches.</p>
<p>I couldn&#8217;t find an available AMF 3 ByteArray writer within the WebORB application server. So first I developed an AMF 3 ByteArray writer class in PHP. The writer class is simple and short because all it needs to do is call other WebORB code classes to perform the work. Next, I went inside the WebORB classes to find the AMF 3 String Writer class. (Hint: All the WebORB AMF 3 Writer classes are in the Writer folder.) I located the AMF 3 String Writer in WebORB&#8217;s MessageWriter class. Next, I added PHP code to intercept the AMF 3 String before it&#8217;s serialized into an AMF 3 stream and then performed two tests, both of which must be true before moving forward with any translation action:</p>
<ol>
<li>Is the string an arbitrarily long string-like 300 bytes?</li>
<li>Do the first few header bytes of the PHP string indicate a JPEG or PNG photo?</li>
</ol>
<p>If the string passed both of the above tests, then I simply transferred the AMF 3 String to my newly written WebORB and AMF 3 ByteArray writer class, which serializes it into a data stream and sends it on its merry way to the SQGallery Flex client.</p>
<p>Guess what? My mapping of the AMF 3 Strings to AMF 3 ByteArrays worked the first time I tried it with a server-to-client photo transfers. After nearly a month of on-and-off frustration, I figured out the issues involved and came up with a solution.</p>
<p>The elapsed time to figure out all of the above and get it working was just short of a month. I&#8217;m not one who gives up easily when the programming syntax and supporting framework don&#8217;t do what I want. Needless to say, it was a good feeling when it all finally worked.</p>
<p>When dealing with server-to-client PHP-based AMF 3 transfers, I hope you will remember the code chicanery I came up with and discussed. And please pass this information along to others who may come upon this barrier of PHP server to AMF 3 client photo data transfers.</p>
<p>It’s perhaps not the cleanest of solutions, but it does the job. I do welcome suggestion of better solutions to handle ByteArray management of photo string data.</p>
<p>The specifics of the changes I made to WebORB for PHP are fully discussed and explained in two documents, &#8220;WebORB 3.6 AS 3 ByteArray Writer Design Notes&#8221; and &#8220;WebORB 3.6 PHP Class Module ByteArray Writer Update Instructions&#8221;. <a href="http://www.seaquest.com/wp-content/downloads/ByteArray/WebORB for PHP Photo ByteArray Transfers.zip">Click here</a> to download these two documents along with the WebORB for PHP server PHP class modifications and additions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seaquest.com/2009/12/18/adobe-amf-3-transfer-of-photo-data-from-a-php-application-server-to-a-adobe-flex-client/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>
